Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
0.00% |
0 / 9 |
|
0.00% |
0 / 3 |
CRAP | |
0.00% |
0 / 1 |
| PandaDocTemplateTokenData | |
0.00% |
0 / 9 |
|
0.00% |
0 / 3 |
12 | |
0.00% |
0 / 1 |
| __construct | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| fromPandaDocResponse | |
0.00% |
0 / 4 |
|
0.00% |
0 / 1 |
2 | |||
| toArray | |
0.00% |
0 / 4 |
|
0.00% |
0 / 1 |
2 | |||
| 1 | <?php |
| 2 | |
| 3 | declare(strict_types=1); |
| 4 | |
| 5 | namespace App\Domain\Document\Data; |
| 6 | |
| 7 | use App\Support\Row; |
| 8 | |
| 9 | final readonly class PandaDocTemplateTokenData |
| 10 | { |
| 11 | public function __construct( |
| 12 | public string $name, |
| 13 | public ?string $defaultValue = null, |
| 14 | ) {} |
| 15 | |
| 16 | /** |
| 17 | * @param array<mixed> $token |
| 18 | */ |
| 19 | public static function fromPandaDocResponse(array $token): self |
| 20 | { |
| 21 | return new self( |
| 22 | name: Row::nullableString($token, 'name') ?? '', |
| 23 | defaultValue: Row::nullableString($token, 'value'), |
| 24 | ); |
| 25 | } |
| 26 | |
| 27 | /** |
| 28 | * @return array<string, mixed> |
| 29 | */ |
| 30 | public function toArray(): array |
| 31 | { |
| 32 | return [ |
| 33 | 'name' => $this->name, |
| 34 | 'defaultValue' => $this->defaultValue, |
| 35 | ]; |
| 36 | } |
| 37 | } |