diff --git a/composer.json b/composer.json index 0bf3712..40b8eca 100644 --- a/composer.json +++ b/composer.json @@ -12,7 +12,8 @@ "symfony/console": "^6.4 || ^7.4 || ^8.1", "symfony/http-client": "^6.4 || ^7.4 || ^8.1", "symfony/http-foundation": "^6.4 || ^7.4 || ^8.1", - "symfony/options-resolver": "^6.4 || ^7.4 || ^8.1" + "symfony/options-resolver": "^6.4 || ^7.4 || ^8.1", + "symfony/translation": "^6.4 || ^7.4 || ^8.1" }, "require-dev": { "ergebnis/composer-normalize": "^2.52", diff --git a/mago.toml b/mago.toml index 1054776..e80afa4 100644 --- a/mago.toml +++ b/mago.toml @@ -59,7 +59,7 @@ cyclomatic-complexity = { } too-many-properties = { - threshold = 11 + threshold = 12 } kan-defect = { diff --git a/src/Model/Matter.php b/src/Model/Matter.php index 2daaebc..c2dded0 100644 --- a/src/Model/Matter.php +++ b/src/Model/Matter.php @@ -4,23 +4,19 @@ namespace ItkDev\F2ApiClient\Model; +use ItkDev\F2ApiClient\Model\Matter\AccessLevel; +use ItkDev\F2ApiClient\Model\Matter\Status; +use ItkDev\F2ApiClient\Model\Matter\Type; + final class Matter extends AbstractF2Item { - // resources/f2-rest-docs/f2-rest-docs-v13s.html#65 - public const string TYPE_INTERNAL = 'Internal'; - public const string TYPE_INBOUND = 'Inbound'; - public const string TYPE_OUTBOUND = 'Outbound'; - - public const string ACCESS_LEVEL_INVOLVED = 'Involved'; - public const string ACCESS_LEVEL_UNIT = 'Unit'; - public const string ACCESS_LEVEL_ALL = 'All'; - public const int TITLE_MAX_LENGTH = 255; public ?string $matterNumber = null; public ?string $title = null; - public ?string $type = null; - public ?string $accessLevel = null; + public ?Type $type = null; + public ?AccessLevel $accessLevel = null; + public ?Status $status = null; public ?bool $archived = null; public ?string $caseNumber = null; public ?\DateTimeImmutable $createdDate = null; @@ -39,8 +35,9 @@ public function setFromSimpleXMLElement(\SimpleXMLElement $sxe): static $this->matterNumber = (string) $sxe->MatterNumber; $this->caseNumber = (string) $sxe->CaseNumber; $this->title = (string) $sxe->Title; - $this->type = (string) $sxe->Type; - $this->accessLevel = (string) $sxe->AccessLevel; + $this->type = Type::from((string) $sxe->Type); + $this->accessLevel = AccessLevel::from((string) $sxe->AccessLevel); + $this->status = Status::from((string) $sxe->Status); $this->archived = $this->parseBoolean($sxe->Archived); $this->createdDate = $this->createDateTime($sxe->CreatedDate); $this->modifiedDate = $this->createDateTime($sxe->ModifiedDate); @@ -64,6 +61,7 @@ public function apiSerialize(): array 'Title' => $this->title, 'Type' => $this->type, 'AccessLevel' => $this->accessLevel, + 'Status' => $this->status, 'Archived' => $this->formatBoolean($this->archived ?? false), ]; if ($this->responsible) { diff --git a/src/Model/Matter/AccessLevel.php b/src/Model/Matter/AccessLevel.php new file mode 100644 index 0000000..59bf832 --- /dev/null +++ b/src/Model/Matter/AccessLevel.php @@ -0,0 +1,25 @@ + $translator->trans('Involved'), + self::Unit => $translator->trans('Unit'), + self::All => $translator->trans('All'), + }; + } +} diff --git a/src/Model/Matter/Status.php b/src/Model/Matter/Status.php new file mode 100644 index 0000000..ab43625 --- /dev/null +++ b/src/Model/Matter/Status.php @@ -0,0 +1,23 @@ + $translator->trans('In progress'), + self::Closed => $translator->trans('Closed'), + }; + } +} diff --git a/src/Model/Matter/Type.php b/src/Model/Matter/Type.php new file mode 100644 index 0000000..a53e793 --- /dev/null +++ b/src/Model/Matter/Type.php @@ -0,0 +1,25 @@ + $translator->trans('Internal'), + self::Inbound => $translator->trans('Inbound'), + self::Outbound => $translator->trans('Outbound'), + }; + } +} diff --git a/tests/Model/MatterTest.php b/tests/Model/MatterTest.php index ef69ba2..8954d5c 100644 --- a/tests/Model/MatterTest.php +++ b/tests/Model/MatterTest.php @@ -14,6 +14,7 @@ public function testMatterApiSerialize(): void 'Title' => null, 'Type' => null, 'AccessLevel' => null, + 'Status' => null, 'Archived' => 'false', ]; $actual = $matter->apiSerialize(); @@ -25,6 +26,7 @@ public function testMatterApiSerialize(): void 'Title' => 'My matter', 'Type' => null, 'AccessLevel' => null, + 'Status' => null, 'Archived' => 'false', ]; $actual = $matter->apiSerialize();