Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
0.00% covered (danger)
0.00%
0 / 23
0.00% covered (danger)
0.00%
0 / 3
CRAP
0.00% covered (danger)
0.00%
0 / 1
DocumentTemplateData
0.00% covered (danger)
0.00%
0 / 23
0.00% covered (danger)
0.00%
0 / 3
12
0.00% covered (danger)
0.00%
0 / 1
 __construct
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
 fromRow
0.00% covered (danger)
0.00%
0 / 11
0.00% covered (danger)
0.00%
0 / 1
2
 toArray
0.00% covered (danger)
0.00%
0 / 11
0.00% covered (danger)
0.00%
0 / 1
2
1<?php
2
3declare(strict_types=1);
4
5namespace App\Domain\Document\Data;
6
7use App\Support\Row;
8
9/**
10 * A registered PandaDoc template the platform sends during registration.
11 *
12 * The {@see $templateId} is the PandaDoc UUID; {@see $active} controls whether
13 * the template is included in the bundle so a template can be retired without
14 * losing its ID.
15 */
16final readonly class DocumentTemplateData
17{
18    public function __construct(
19        public string $templateId,
20        public string $name,
21        public ?string $description,
22        public bool $active,
23        public int $displayOrder,
24        public string $recipientRole,
25        public bool $requiresIdVerification,
26        public string $createdAt,
27        public string $updatedAt,
28    ) {}
29
30    /**
31     * @param array<mixed> $row Repository row with camelCase aliases
32     */
33    public static function fromRow(array $row): self
34    {
35        return new self(
36            templateId: Row::string($row, 'templateId'),
37            name: Row::string($row, 'name'),
38            description: Row::nullableString($row, 'description'),
39            active: (bool)$row['active'],
40            displayOrder: Row::int($row, 'displayOrder'),
41            recipientRole: Row::string($row, 'recipientRole'),
42            requiresIdVerification: (bool)$row['requiresIdVerification'],
43            createdAt: Row::string($row, 'createdAt'),
44            updatedAt: Row::string($row, 'updatedAt'),
45        );
46    }
47
48    /**
49     * @return array<string, mixed>
50     */
51    public function toArray(): array
52    {
53        return [
54            'templateId' => $this->templateId,
55            'name' => $this->name,
56            'description' => $this->description,
57            'active' => $this->active,
58            'displayOrder' => $this->displayOrder,
59            'recipientRole' => $this->recipientRole,
60            'requiresIdVerification' => $this->requiresIdVerification,
61            'createdAt' => $this->createdAt,
62            'updatedAt' => $this->updatedAt,
63        ];
64    }
65}