castopod/modules/Plugins/Manifest/Manifest.php

82 lines
2.1 KiB
PHP

<?php
declare(strict_types=1);
namespace Modules\Plugins\Manifest;
use CodeIgniter\HTTP\URI;
/**
* @property string $name
* @property string $version
* @property ?string $description
* @property ?Author $author
* @property Author[] $authors
* @property ?URI $homepage
* @property ?string $license
* @property bool $private
* @property list<string> $keywords
* @property list<string> $hooks
* @property ?Settings $settings
*/
class Manifest extends ManifestObject
{
/**
* @var array<string,string>
*/
protected const VALIDATION_RULES = [
'name' => 'required|max_length[32]',
'version' => 'required|regex_match[/^(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)(?:-((?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*)(?:\.(?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*))*))?(?:\+([0-9a-zA-Z-]+(?:\.[0-9a-zA-Z-]+)*))?$/]',
'description' => 'permit_empty|max_length[128]',
'author' => 'permit_empty',
'authors' => 'permit_empty|is_list',
'homepage' => 'permit_empty|valid_url_strict',
'license' => 'permit_empty|string',
'private' => 'permit_empty|is_boolean',
'keywords.*' => 'permit_empty',
'hooks.*' => 'permit_empty|in_list[channelTag,itemTag,siteHead]',
'settings' => 'permit_empty',
];
/**
* @var array<string,array{string}|string>
*/
protected const CASTS = [
'author' => Author::class,
'authors' => [Author::class],
'homepage' => URI::class,
'settings' => Settings::class,
];
protected string $name;
protected string $version;
protected ?string $description = null;
protected ?Author $author = null;
/**
* @var Author[]
*/
protected array $authors = [];
protected ?URI $homepage = null;
protected ?string $license = null;
protected bool $private = false;
/**
* @var list<string>
*/
protected array $keywords = [];
/**
* @var list<string>
*/
protected array $hooks = [];
protected ?Settings $settings = null;
}