Total Complexity | 3 |
Total Lines | 72 |
Duplicated Lines | 0 % |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
17 | #[Attribute(Attribute::TARGET_METHOD | Attribute::IS_REPEATABLE)] |
||
18 | final class Link implements JsonSerializable |
||
19 | { |
||
20 | /** |
||
21 | * Relation to the target resource of the link |
||
22 | * |
||
23 | * @var string |
||
24 | */ |
||
25 | public $rel; |
||
26 | |||
27 | /** |
||
28 | * A URI template, as defined by RFC 6570 |
||
29 | * |
||
30 | * @var string |
||
31 | */ |
||
32 | public $href; |
||
33 | |||
34 | /** |
||
35 | * A method for the Link |
||
36 | * |
||
37 | * @var string |
||
38 | * @Enum({"get", "post", "put", "patch", "delete"}) |
||
39 | */ |
||
40 | public $method; |
||
41 | |||
42 | /** |
||
43 | * A title for the link |
||
44 | * |
||
45 | * @var string |
||
46 | */ |
||
47 | public $title; |
||
48 | |||
49 | /** |
||
50 | * Crawl tag ID for crawl request |
||
51 | * |
||
52 | * @var string |
||
53 | */ |
||
54 | public $crawl; |
||
55 | |||
56 | /** |
||
57 | * @return string[] |
||
58 | * @psalm-return array{rel: string, href: string, method: string, title?: string} |
||
59 | */ |
||
60 | #[Override] |
||
61 | public function jsonSerialize(): array |
||
62 | { |
||
63 | $json = [ |
||
64 | 'rel' => $this->rel, |
||
65 | 'href' => $this->href, |
||
66 | 'method' => $this->method, |
||
67 | ]; |
||
68 | if ($this->title) { |
||
69 | $json += ['title' => $this->title]; |
||
70 | } |
||
71 | |||
72 | return $json; |
||
73 | } |
||
74 | |||
75 | /** @param array{rel?: string, href?: string, method?: string, title?: string, crawl?:string} $values */ |
||
76 | public function __construct( |
||
89 | } |
||
90 | } |
||
91 |