Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
2 changes: 1 addition & 1 deletion mago.toml
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ cyclomatic-complexity = {
}

too-many-properties = {
threshold = 11
threshold = 12
}

kan-defect = {
Expand Down
24 changes: 11 additions & 13 deletions src/Model/Matter.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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);
Expand All @@ -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) {
Expand Down
25 changes: 25 additions & 0 deletions src/Model/Matter/AccessLevel.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<?php

declare(strict_types=1);

namespace ItkDev\F2ApiClient\Model\Matter;

use Symfony\Contracts\Translation\TranslatableInterface;
use Symfony\Contracts\Translation\TranslatorInterface;

enum AccessLevel: string implements TranslatableInterface
{
// resources/f2-rest-docs/f2-rest-docs-v13s.html#65
case Involved = 'Involved';
case Unit = 'Unit';
case All = 'All';

public function trans(TranslatorInterface $translator, ?string $locale = null): string
{
return match ($this) {
self::Involved => $translator->trans('Involved'),
self::Unit => $translator->trans('Unit'),
self::All => $translator->trans('All'),
};
}
}
23 changes: 23 additions & 0 deletions src/Model/Matter/Status.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<?php

declare(strict_types=1);

namespace ItkDev\F2ApiClient\Model\Matter;

use Symfony\Contracts\Translation\TranslatableInterface;
use Symfony\Contracts\Translation\TranslatorInterface;

enum Status: string implements TranslatableInterface
{
// resources/f2-rest-docs/f2-rest-docs-v13s.html#65
case InProgress = 'InProgress';
case Closed = 'Closed';

public function trans(TranslatorInterface $translator, ?string $locale = null): string
{
return match ($this) {
self::InProgress => $translator->trans('In progress'),
self::Closed => $translator->trans('Closed'),
};
}
}
25 changes: 25 additions & 0 deletions src/Model/Matter/Type.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<?php

declare(strict_types=1);

namespace ItkDev\F2ApiClient\Model\Matter;

use Symfony\Contracts\Translation\TranslatableInterface;
use Symfony\Contracts\Translation\TranslatorInterface;

enum Type: string implements TranslatableInterface
{
// resources/f2-rest-docs/f2-rest-docs-v13s.html#65
case Internal = 'Internal';
case Inbound = 'Inbound';
case Outbound = 'Outbound';

public function trans(TranslatorInterface $translator, ?string $locale = null): string
{
return match ($this) {
self::Internal => $translator->trans('Internal'),
self::Inbound => $translator->trans('Inbound'),
self::Outbound => $translator->trans('Outbound'),
};
}
}
2 changes: 2 additions & 0 deletions tests/Model/MatterTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ public function testMatterApiSerialize(): void
'Title' => null,
'Type' => null,
'AccessLevel' => null,
'Status' => null,
'Archived' => 'false',
];
$actual = $matter->apiSerialize();
Expand All @@ -25,6 +26,7 @@ public function testMatterApiSerialize(): void
'Title' => 'My matter',
'Type' => null,
'AccessLevel' => null,
'Status' => null,
'Archived' => 'false',
];
$actual = $matter->apiSerialize();
Expand Down
Loading