Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
0.00% covered (danger)
0.00%
0 / 9
0.00% covered (danger)
0.00%
0 / 3
CRAP
0.00% covered (danger)
0.00%
0 / 1
PandaDocDocumentRefData
0.00% covered (danger)
0.00%
0 / 9
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
 fromPandaDocResponse
0.00% covered (danger)
0.00%
0 / 4
0.00% covered (danger)
0.00%
0 / 1
2
 toArray
0.00% covered (danger)
0.00%
0 / 4
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 lightweight reference to a freshly-created PandaDoc document — only
11 * the id and current status. Used by the document-creation flow before
12 * the full document details are available.
13 */
14final readonly class PandaDocDocumentRefData
15{
16    public function __construct(
17        public string $id = '',
18        public string $status = '',
19    ) {}
20
21    /**
22     * Build from a PandaDoc create-document API response.
23     *
24     * @param array<mixed> $response
25     */
26    public static function fromPandaDocResponse(array $response): self
27    {
28        return new self(
29            id: Row::nullableString($response, 'id') ?? '',
30            status: Row::nullableString($response, 'status') ?? '',
31        );
32    }
33
34    /**
35     * @return array<string, mixed>
36     */
37    public function toArray(): array
38    {
39        return [
40            'id' => $this->id,
41            'status' => $this->status,
42        ];
43    }
44}