From a1065e977c188c2eb919e54282bd46d7504cbf2e Mon Sep 17 00:00:00 2001 From: Mikkel Ricky Date: Wed, 11 Nov 2026 14:19:39 +0100 Subject: [PATCH 1/2] Added status on matter --- mago.toml | 2 +- src/Model/Matter.php | 6 ++++++ tests/Model/MatterTest.php | 2 ++ 3 files changed, 9 insertions(+), 1 deletion(-) 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..814ab8b 100644 --- a/src/Model/Matter.php +++ b/src/Model/Matter.php @@ -11,6 +11,9 @@ final class Matter extends AbstractF2Item public const string TYPE_INBOUND = 'Inbound'; public const string TYPE_OUTBOUND = 'Outbound'; + public const string STATUS_IN_PROGRESS = 'InProgress'; + public const string STATUS_CLOSED = 'Closed'; + public const string ACCESS_LEVEL_INVOLVED = 'Involved'; public const string ACCESS_LEVEL_UNIT = 'Unit'; public const string ACCESS_LEVEL_ALL = 'All'; @@ -21,6 +24,7 @@ final class Matter extends AbstractF2Item public ?string $title = null; public ?string $type = null; public ?string $accessLevel = null; + public ?string $status = null; public ?bool $archived = null; public ?string $caseNumber = null; public ?\DateTimeImmutable $createdDate = null; @@ -41,6 +45,7 @@ public function setFromSimpleXMLElement(\SimpleXMLElement $sxe): static $this->title = (string) $sxe->Title; $this->type = (string) $sxe->Type; $this->accessLevel = (string) $sxe->AccessLevel; + $this->status = (string) $sxe->Status; $this->archived = $this->parseBoolean($sxe->Archived); $this->createdDate = $this->createDateTime($sxe->CreatedDate); $this->modifiedDate = $this->createDateTime($sxe->ModifiedDate); @@ -64,6 +69,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/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(); From d33dd683324bfc4b7d2ecc920d94dda9b122e472 Mon Sep 17 00:00:00 2001 From: Mikkel Ricky Date: Wed, 11 Nov 2026 14:32:48 +0100 Subject: [PATCH 2/2] Used enums for enums --- composer.json | 3 ++- src/Model/Matter.php | 28 ++++++++++------------------ src/Model/Matter/AccessLevel.php | 25 +++++++++++++++++++++++++ src/Model/Matter/Status.php | 23 +++++++++++++++++++++++ src/Model/Matter/Type.php | 25 +++++++++++++++++++++++++ 5 files changed, 85 insertions(+), 19 deletions(-) create mode 100644 src/Model/Matter/AccessLevel.php create mode 100644 src/Model/Matter/Status.php create mode 100644 src/Model/Matter/Type.php 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/src/Model/Matter.php b/src/Model/Matter.php index 814ab8b..c2dded0 100644 --- a/src/Model/Matter.php +++ b/src/Model/Matter.php @@ -4,27 +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 STATUS_IN_PROGRESS = 'InProgress'; - public const string STATUS_CLOSED = 'Closed'; - - 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 ?string $status = 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; @@ -43,9 +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->status = (string) $sxe->Status; + $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); 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'), + }; + } +}