feat: add enum

This commit is contained in:
Maël Gangloff 2024-07-11 13:15:04 +02:00
parent fbb14df399
commit f6bd04ba17
No known key found for this signature in database
GPG Key ID: 11FDC81C24A7F629
11 changed files with 206 additions and 162 deletions

View File

@ -11,9 +11,9 @@
"doctrine/doctrine-bundle": "^2.12",
"doctrine/doctrine-migrations-bundle": "^3.3",
"doctrine/orm": "^3.2",
"eluceo/ical": "^2.13",
"phpdocumentor/reflection-docblock": "^5.4",
"phpstan/phpdoc-parser": "^1.29",
"spatie/icalendar-generator": "^2.8",
"symfony/asset": "7.1.*",
"symfony/asset-mapper": "7.1.*",
"symfony/console": "7.1.*",

202
composer.lock generated
View File

@ -4,7 +4,7 @@
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
"This file is @generated automatically"
],
"content-hash": "2c9a601dd6b90ee988fc2c8205c79665",
"content-hash": "d9421147fcd12ef355e47fc4e69d67ef",
"packages": [
{
"name": "composer/semver",
@ -1376,6 +1376,70 @@
],
"time": "2023-10-06T06:47:41+00:00"
},
{
"name": "eluceo/ical",
"version": "2.13.0",
"source": {
"type": "git",
"url": "https://github.com/markuspoerschke/iCal.git",
"reference": "43fd5991032d46db06ae0b3f67416adfdad38336"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/markuspoerschke/iCal/zipball/43fd5991032d46db06ae0b3f67416adfdad38336",
"reference": "43fd5991032d46db06ae0b3f67416adfdad38336",
"shasum": ""
},
"require": {
"ext-mbstring": "*",
"php": ">=7.4 || ~8.0.0 || ~8.1.0 || ~8.2.0 || ~8.3.0",
"symfony/deprecation-contracts": "^2.1 || ^3.0"
},
"conflict": {
"php": "7.4.6"
},
"require-dev": {
"ergebnis/composer-normalize": "^2.23.1",
"friendsofphp/php-cs-fixer": "^3.4",
"infection/infection": "^0.23 || ^0.26 || ^0.27",
"phpmd/phpmd": "^2.13",
"phpunit/phpunit": "^9.5",
"vimeo/psalm": "^4.8 || ^5.0"
},
"type": "library",
"autoload": {
"psr-4": {
"Eluceo\\iCal\\": "src/"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Markus Poerschke",
"email": "markus@poerschke.nrw",
"role": "Developer"
}
],
"description": "The eluceo/iCal package offers an abstraction layer for creating iCalendars. You can easily create iCal files by using PHP objects instead of typing your *.ics file by hand. The output will follow RFC 5545 as best as possible.",
"homepage": "https://github.com/markuspoerschke/iCal",
"keywords": [
"calendar",
"iCalendar",
"ical",
"ics",
"php calendar"
],
"support": {
"docs": "https://ical.poerschke.nrw",
"forum": "https://github.com/markuspoerschke/iCal/discussions",
"issues": "https://github.com/markuspoerschke/iCal/issues",
"source": "https://github.com/markuspoerschke/iCal"
},
"time": "2023-12-19T19:24:37+00:00"
},
{
"name": "monolog/monolog",
"version": "3.7.0",
@ -2005,142 +2069,6 @@
},
"time": "2021-07-14T16:46:02+00:00"
},
{
"name": "spatie/enum",
"version": "3.13.0",
"source": {
"type": "git",
"url": "https://github.com/spatie/enum.git",
"reference": "f1a0f464ba909491a53e60a955ce84ad7cd93a2c"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/spatie/enum/zipball/f1a0f464ba909491a53e60a955ce84ad7cd93a2c",
"reference": "f1a0f464ba909491a53e60a955ce84ad7cd93a2c",
"shasum": ""
},
"require": {
"ext-json": "*",
"php": "^8.0"
},
"require-dev": {
"fakerphp/faker": "^1.9.1",
"larapack/dd": "^1.1",
"phpunit/phpunit": "^9.0",
"vimeo/psalm": "^4.3"
},
"suggest": {
"fakerphp/faker": "To use the enum faker provider",
"phpunit/phpunit": "To use the enum assertions"
},
"type": "library",
"autoload": {
"psr-4": {
"Spatie\\Enum\\": "src"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Brent Roose",
"email": "brent@spatie.be",
"homepage": "https://spatie.be",
"role": "Developer"
},
{
"name": "Tom Witkowski",
"email": "dev@gummibeer.de",
"homepage": "https://gummibeer.de",
"role": "Developer"
}
],
"description": "PHP Enums",
"homepage": "https://github.com/spatie/enum",
"keywords": [
"enum",
"enumerable",
"spatie"
],
"support": {
"docs": "https://docs.spatie.be/enum",
"issues": "https://github.com/spatie/enum/issues",
"source": "https://github.com/spatie/enum"
},
"funding": [
{
"url": "https://spatie.be/open-source/support-us",
"type": "custom"
},
{
"url": "https://github.com/spatie",
"type": "github"
}
],
"time": "2022-04-22T08:51:55+00:00"
},
{
"name": "spatie/icalendar-generator",
"version": "2.8.1",
"source": {
"type": "git",
"url": "https://github.com/spatie/icalendar-generator.git",
"reference": "6cb8b9b9df72bbea25b302aabce680917739fdb6"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/spatie/icalendar-generator/zipball/6cb8b9b9df72bbea25b302aabce680917739fdb6",
"reference": "6cb8b9b9df72bbea25b302aabce680917739fdb6",
"shasum": ""
},
"require": {
"ext-mbstring": "*",
"php": "^8.1",
"spatie/enum": "^3.11"
},
"require-dev": {
"ext-json": "*",
"larapack/dd": "^1.1",
"nesbot/carbon": "^3.5",
"pestphp/pest": "^2.34",
"spatie/pest-plugin-snapshots": "^2.1",
"vimeo/psalm": "^5.24"
},
"type": "library",
"autoload": {
"psr-4": {
"Spatie\\IcalendarGenerator\\": "src"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Ruben Van Assche",
"email": "ruben@spatie.be",
"homepage": "https://spatie.be",
"role": "Developer"
}
],
"description": "Build calendars in the iCalendar format",
"homepage": "https://github.com/spatie/icalendar-generator",
"keywords": [
"calendar",
"iCalendar",
"ical",
"ics",
"spatie"
],
"support": {
"issues": "https://github.com/spatie/icalendar-generator/issues",
"source": "https://github.com/spatie/icalendar-generator/tree/2.8.1"
},
"time": "2024-06-17T11:23:50+00:00"
},
{
"name": "symfony/asset",
"version": "v7.1.1",

View File

@ -10,7 +10,7 @@ use Doctrine\Migrations\AbstractMigration;
/**
* Auto-generated Migration: Please modify to your needs!
*/
final class Version20240711002439 extends AbstractMigration
final class Version20240711111301 extends AbstractMigration
{
public function getDescription(): string
{
@ -22,8 +22,8 @@ final class Version20240711002439 extends AbstractMigration
// this up() migration is auto-generated, please modify it to your needs
$this->addSql('CREATE TABLE bookmark_domain_list (token VARCHAR(36) NOT NULL, user_id INTEGER NOT NULL, PRIMARY KEY(token), CONSTRAINT FK_F05EDCECA76ED395 FOREIGN KEY (user_id) REFERENCES user (id) NOT DEFERRABLE INITIALLY IMMEDIATE)');
$this->addSql('CREATE INDEX IDX_F05EDCECA76ED395 ON bookmark_domain_list (user_id)');
$this->addSql('CREATE TABLE domain (ldhname VARCHAR(255) NOT NULL, handle VARCHAR(255) NOT NULL, status CLOB NOT NULL --(DC2Type:simple_array)
, whois_status VARCHAR(255) NOT NULL, PRIMARY KEY(ldhname))');
$this->addSql('CREATE TABLE domain (ldhname VARCHAR(255) NOT NULL, handle VARCHAR(255) NOT NULL, whois_status VARCHAR(255) NOT NULL, status CLOB NOT NULL --(DC2Type:simple_array)
, PRIMARY KEY(ldhname))');
$this->addSql('CREATE TABLE domain_entity (domain_id VARCHAR(255) NOT NULL, entity_id VARCHAR(255) NOT NULL, roles CLOB NOT NULL --(DC2Type:simple_array)
, PRIMARY KEY(domain_id, entity_id), CONSTRAINT FK_614B48A1115F0EE5 FOREIGN KEY (domain_id) REFERENCES domain (ldhname) NOT DEFERRABLE INITIALLY IMMEDIATE, CONSTRAINT FK_614B48A181257D5D FOREIGN KEY (entity_id) REFERENCES entity (handle) NOT DEFERRABLE INITIALLY IMMEDIATE)');
$this->addSql('CREATE INDEX IDX_614B48A1115F0EE5 ON domain_entity (domain_id)');
@ -32,7 +32,7 @@ final class Version20240711002439 extends AbstractMigration
$this->addSql('CREATE TABLE event ("action" VARCHAR(255) NOT NULL, domain_id VARCHAR(255) NOT NULL, date DATE NOT NULL --(DC2Type:date_immutable)
, PRIMARY KEY("action", domain_id), CONSTRAINT FK_3BAE0AA7115F0EE5 FOREIGN KEY (domain_id) REFERENCES domain (ldhname) NOT DEFERRABLE INITIALLY IMMEDIATE)');
$this->addSql('CREATE INDEX IDX_3BAE0AA7115F0EE5 ON event (domain_id)');
$this->addSql('CREATE TABLE nameserver (handle VARCHAR(255) NOT NULL, ldhname VARCHAR(255) NOT NULL, status CLOB NOT NULL --(DC2Type:array)
$this->addSql('CREATE TABLE nameserver (handle VARCHAR(255) NOT NULL, ldhname VARCHAR(255) NOT NULL, status CLOB NOT NULL --(DC2Type:simple_array)
, PRIMARY KEY(handle))');
$this->addSql('CREATE TABLE nameserver_entity (nameserver_id VARCHAR(255) NOT NULL, entity_id VARCHAR(255) NOT NULL, roles CLOB NOT NULL --(DC2Type:simple_array)
, status CLOB NOT NULL --(DC2Type:simple_array)

18
src/Config/DomainRole.php Normal file
View File

@ -0,0 +1,18 @@
<?php
namespace App\Config;
enum DomainRole: string
{
case Registrant = 'registrant';
case Technical = 'technical';
case Administrative = 'administrative';
case Abuse = 'abuse';
case Billing = 'billing';
case Registrar = 'registrar';
case Reseller = 'reseller';
case Sponsor = 'sponsor';
case Proxy = 'proxy';
case Notifications = 'notifications';
case Noc = 'noc';
}

View File

@ -0,0 +1,43 @@
<?php
namespace App\Config;
enum DomainStatus: string
{
case Validated = 'validated';
case RenewProhibited = 'renew prohibited';
case UpdateProhibited = 'update prohibited';
case TransferProhibited = 'transfer prohibited';
case DeleteProhibited = 'delete prohibited';
case Proxy = 'proxy';
case Private = 'private';
case Removed = 'removed';
case Obscured = 'obscured';
case Associated = 'associated';
case Active = 'active';
case Inactive = 'inactive';
case Locked = 'locked';
case PendingCreate = 'pending create';
case PendingRenew = 'pending renew';
case PendingTransfer = 'pending transfer';
case PendingUpdate = 'pending update';
case PendingDelete = 'pending delete';
case AddPeriod = 'add period';
case AutoRenewPeriod = 'auto renew period';
case ClientDeleteProhibited = 'client delete prohibited';
case ClientHold = 'client hold';
case ClientRenewProhibited = 'client renew prohibited';
case ClientTransferProhibited = 'client transfer prohibited';
case ClientUpdateProhibited = 'client update prohibited';
case PendingRestore = 'pending restore';
case RedemptionPeriod = 'redemption period';
case RenewPeriod = 'renew period';
case ServerDeleteProhibited = 'server delete prohibited';
case ServerRenewProhibited = 'server renew prohibited';
case ServerTransferProhibited = 'server transfer prohibited';
case ServerUpdateProhibited = 'server update prohibited';
case ServerHold = 'server hold';
case TransferPeriod = 'transfer period';
case Administrative = 'administrative';
case Reserved = 'reserved';
}

View File

@ -0,0 +1,12 @@
<?php
namespace App\Config;
enum DomainVariantRelation: string
{
case Registered = 'registered';
case Unregistered = 'unregistered';
case RegistrationRestricted = 'registration restricted';
case OpenRegistration = 'open registration';
case Conjoined = 'conjoined';
}

View File

@ -0,0 +1,19 @@
<?php
namespace App\Config;
enum EventAction: string
{
case Registration = 'registration';
case Reregistration = 'reregistration';
case LastChanged = 'last changed';
case Expiration = 'expiration';
case Deletion = 'deletion';
case Reinstantiation = 'reinstantiation';
case Transfer = 'transfer';
case Locked = 'locked';
case Unlocked = 'unlocked';
case LastUpdateOfRDAPDatabase = 'last update of RDAP database';
case RegistrarExpiration = 'registrar expiration';
case EnumValidationExpiration = 'enum validation expiration';
}

View File

@ -2,6 +2,7 @@
namespace App\Entity;
use App\Config\DomainStatus;
use App\Repository\DomainRepository;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
@ -18,9 +19,6 @@ class Domain
#[ORM\Column(length: 255)]
private ?string $handle = null;
#[ORM\Column(type: Types::SIMPLE_ARRAY)]
private array $status = [];
/**
* @var Collection<int, Event>
*/
@ -36,6 +34,9 @@ class Domain
#[ORM\Column(length: 255)]
private ?string $whoisStatus = null;
#[ORM\Column(type: Types::SIMPLE_ARRAY, enumType: DomainStatus::class)]
private array $status = [];
public function __construct()
{
$this->events = new ArrayCollection();
@ -66,18 +67,6 @@ class Domain
return $this;
}
public function getStatus(): array
{
return $this->status;
}
public function setStatus(array $status): static
{
$this->status = $status;
return $this;
}
/**
* @return Collection<int, Event>
*/
@ -149,4 +138,19 @@ class Domain
return $this;
}
/**
* @return DomainStatus[]
*/
public function getStatus(): array
{
return $this->status;
}
public function setStatus(array $status): static
{
$this->status = $status;
return $this;
}
}

View File

@ -2,6 +2,7 @@
namespace App\Entity;
use App\Config\DomainRole;
use App\Repository\DomainEntityRepository;
use Doctrine\DBAL\Types\Types;
use Doctrine\ORM\Mapping as ORM;
@ -19,9 +20,10 @@ class DomainEntity
#[ORM\JoinColumn(referencedColumnName: 'handle', nullable: false)]
private ?Entity $entity = null;
#[ORM\Column(type: Types::SIMPLE_ARRAY)]
#[ORM\Column(type: Types::SIMPLE_ARRAY, enumType: DomainRole::class)]
private array $roles = [];
public function getDomain(): ?Domain
{
return $this->domain;
@ -46,7 +48,10 @@ class DomainEntity
return $this;
}
public function getRoles(): ?array
/**
* @return DomainRole[]
*/
public function getRoles(): array
{
return $this->roles;
}
@ -57,4 +62,5 @@ class DomainEntity
return $this;
}
}

View File

@ -2,6 +2,7 @@
namespace App\Entity;
use App\Config\DomainStatus;
use App\Repository\NameserverRepository;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
@ -24,7 +25,7 @@ class Nameserver
#[ORM\OneToMany(targetEntity: NameserverEntity::class, mappedBy: 'nameserver', orphanRemoval: true)]
private Collection $nameserverEntities;
#[ORM\Column(type: Types::ARRAY)]
#[ORM\Column(type: Types::SIMPLE_ARRAY, enumType: DomainStatus::class)]
private array $status = [];
public function __construct()
@ -86,6 +87,9 @@ class Nameserver
return $this;
}
/**
* @return DomainStatus[]
*/
public function getStatus(): array
{
return $this->status;
@ -97,4 +101,5 @@ class Nameserver
return $this;
}
}

View File

@ -2,6 +2,8 @@
namespace App\Entity;
use App\Config\DomainRole;
use App\Config\DomainStatus;
use App\Repository\NameserverEntityRepository;
use Doctrine\DBAL\Types\Types;
use Doctrine\ORM\Mapping as ORM;
@ -19,10 +21,10 @@ class NameserverEntity
#[ORM\JoinColumn(referencedColumnName: 'handle', nullable: false)]
private ?Entity $entity = null;
#[ORM\Column(type: Types::SIMPLE_ARRAY)]
#[ORM\Column(type: Types::SIMPLE_ARRAY, enumType: DomainRole::class)]
private array $roles = [];
#[ORM\Column(type: Types::SIMPLE_ARRAY)]
#[ORM\Column(type: Types::SIMPLE_ARRAY, enumType: DomainStatus::class)]
private array $status = [];
public function getNameserver(): ?Nameserver
@ -49,6 +51,9 @@ class NameserverEntity
return $this;
}
/**
* @return DomainRole[]
*/
public function getRoles(): array
{
return $this->roles;
@ -61,6 +66,9 @@ class NameserverEntity
return $this;
}
/**
* @return DomainStatus[]
*/
public function getStatus(): array
{
return $this->status;
@ -72,4 +80,5 @@ class NameserverEntity
return $this;
}
}