1 | <?php |
||
17 | trait RelationshipsContainer |
||
18 | { |
||
19 | /** |
||
20 | * Relationships |
||
21 | * |
||
22 | * @var AbstractRelationship[] |
||
23 | */ |
||
24 | protected $relationships = []; |
||
25 | |||
26 | /** |
||
27 | * Set relationship |
||
28 | * |
||
29 | * @param string $name |
||
30 | * @param AbstractRelationship $relationship |
||
31 | */ |
||
32 | 4 | public function setRelationship(string $name, AbstractRelationship $relationship) |
|
40 | |||
41 | /** |
||
42 | * Has relationship |
||
43 | * |
||
44 | * @param string $name |
||
45 | * @return bool |
||
46 | */ |
||
47 | 2 | public function hasRelationship(string $name): bool |
|
51 | |||
52 | /** |
||
53 | * Get relationship |
||
54 | * |
||
55 | * @param string $name |
||
56 | * @return AbstractRelationship |
||
57 | */ |
||
58 | 2 | public function getRelationship(string $name): AbstractRelationship |
|
66 | |||
67 | /** |
||
68 | * Contains any relationships ? |
||
69 | * |
||
70 | * @return bool |
||
71 | */ |
||
72 | public function hasRelationships(): bool |
||
76 | |||
77 | /** |
||
78 | * Get relationships |
||
79 | * |
||
80 | * @return AbstractRelationship[] |
||
81 | */ |
||
82 | 1 | public function getRelationships(): array |
|
86 | |||
87 | /** |
||
88 | * Remove relationship |
||
89 | * |
||
90 | * @param string $name |
||
91 | */ |
||
92 | 1 | public function removeRelationship(string $name) |
|
96 | |||
97 | /** |
||
98 | * Cast relationships to an array |
||
99 | * |
||
100 | * @return array |
||
101 | */ |
||
102 | 5 | protected function relationshipsToArray(): array |
|
113 | } |