1 | <?php |
||
14 | class Definition implements LinksAwareInterface |
||
15 | { |
||
16 | use LinksContainer; |
||
17 | |||
18 | /** |
||
19 | * Class covered by definition |
||
20 | * |
||
21 | * @var string |
||
22 | */ |
||
23 | protected $class; |
||
24 | |||
25 | /** |
||
26 | * Resource type |
||
27 | * |
||
28 | * @var string |
||
29 | */ |
||
30 | protected $type; |
||
31 | |||
32 | /** |
||
33 | * Attributes |
||
34 | * |
||
35 | * @var Attribute[] |
||
36 | */ |
||
37 | protected $attributes = []; |
||
38 | |||
39 | /** |
||
40 | * Relationships |
||
41 | * |
||
42 | * @var Relationship[] |
||
43 | */ |
||
44 | protected $relationships = []; |
||
45 | |||
46 | /** |
||
47 | * Definition constructor. |
||
48 | * |
||
49 | * @param string $class |
||
50 | */ |
||
51 | 19 | public function __construct(string $class) |
|
55 | |||
56 | /** |
||
57 | * Get class covered by definition |
||
58 | * |
||
59 | * @return string |
||
60 | */ |
||
61 | 2 | public function getClass(): string |
|
65 | |||
66 | /** |
||
67 | * Set type of resource |
||
68 | * |
||
69 | * @param string $type |
||
70 | */ |
||
71 | 7 | public function setType(string $type) |
|
75 | |||
76 | /** |
||
77 | * Has type of resource defined ? |
||
78 | * |
||
79 | * @return bool |
||
80 | */ |
||
81 | 3 | public function hasType(): bool |
|
85 | |||
86 | /** |
||
87 | * Get type of resource |
||
88 | * |
||
89 | * @return string |
||
90 | */ |
||
91 | 3 | public function getType(): string |
|
95 | |||
96 | /** |
||
97 | * Add attribute |
||
98 | * |
||
99 | * @param Attribute $attribute |
||
100 | * @throws \LogicException |
||
101 | */ |
||
102 | public function addAttribute(Attribute $attribute) |
||
112 | |||
113 | /** |
||
114 | * Get attributes |
||
115 | * |
||
116 | * @return Attribute[] |
||
117 | */ |
||
118 | 1 | public function getAttributes(): array |
|
122 | |||
123 | /** |
||
124 | * Add relationship |
||
125 | * |
||
126 | * @param Relationship $relationship |
||
127 | * @throws \LogicException |
||
128 | */ |
||
129 | 10 | public function addRelationship(Relationship $relationship) |
|
139 | |||
140 | /** |
||
141 | * Get relationships |
||
142 | * |
||
143 | * @return Relationship[] |
||
144 | */ |
||
145 | 8 | public function getRelationships(): array |
|
149 | } |