1 | <?php |
||
8 | abstract class Relationship { |
||
9 | |||
10 | const ONE_TO_ONE = 'one-to-one'; |
||
11 | const ONE_TO_MANY = 'one-to-many'; |
||
12 | const MANY_TO_MANY = 'many-to-many'; |
||
13 | |||
14 | /** @var Table */ |
||
15 | protected $model; |
||
16 | |||
17 | /** @var Table */ |
||
18 | protected $foreign; |
||
19 | |||
20 | /** @var ForeignKey */ |
||
21 | protected $fk; |
||
22 | |||
23 | /** |
||
24 | * Returns the type of this relationship |
||
25 | * |
||
26 | * @return string |
||
27 | */ |
||
28 | abstract public function getType(); |
||
29 | |||
30 | public function isOneToOne() { |
||
33 | |||
34 | /** |
||
35 | * Returns the model |
||
36 | * |
||
37 | * @return Table |
||
38 | */ |
||
39 | public function getModel() { |
||
42 | |||
43 | /** |
||
44 | * Returns the foreign model |
||
45 | * |
||
46 | * @return Table |
||
47 | */ |
||
48 | public function getForeign() { |
||
51 | |||
52 | /** |
||
53 | * Returns the foreign key |
||
54 | * |
||
55 | * @return ForeignKey |
||
56 | */ |
||
57 | public function getForeignKey() { |
||
60 | |||
61 | /** |
||
62 | * Returns the related name in studly case |
||
63 | * |
||
64 | * @return string |
||
65 | */ |
||
66 | abstract public function getRelatedName(); |
||
67 | |||
68 | /** |
||
69 | * Returns the pluralized related name in studly case |
||
70 | * |
||
71 | * @return string |
||
72 | */ |
||
73 | public function getRelatedPluralName() { |
||
76 | |||
77 | /** |
||
78 | * Returns the related type name for usage in api environment (slug, type-name, etc) |
||
79 | * |
||
80 | * @return string |
||
81 | */ |
||
82 | public function getRelatedTypeName() { |
||
85 | |||
86 | /** |
||
87 | * Returns the pluralized related type name for usage in api environment (slug, type-name, etc) |
||
88 | * |
||
89 | * @return string |
||
90 | */ |
||
91 | public function getRelatedPluralTypeName() { |
||
94 | |||
95 | /** |
||
96 | * Returns the reverse related name in studly case |
||
97 | */ |
||
98 | abstract public function getReverseRelatedName(); |
||
99 | |||
100 | /** |
||
101 | * Returns the pluralized reverse related name in studly case |
||
102 | * |
||
103 | * @return string |
||
104 | */ |
||
105 | public function getReverseRelatedPluralName() { |
||
108 | |||
109 | /** |
||
110 | * Returns the reverse related type name for usage in api environment (slug, type-name, etc) |
||
111 | * |
||
112 | * @return string |
||
113 | */ |
||
114 | public function getReverseRelatedTypeName() { |
||
117 | |||
118 | /** |
||
119 | * Returns the pluralized reverse related type name for usage in api environment (slug, type-name, etc) |
||
120 | * |
||
121 | * @return string |
||
122 | */ |
||
123 | public function getReverseRelatedPluralTypeName() { |
||
126 | |||
127 | /** |
||
128 | * Returns whether the relationship refers to itself |
||
129 | * |
||
130 | * @return bool |
||
131 | */ |
||
132 | public function isReflexive() { |
||
135 | } |
This check looks for accesses to local static members using the fully qualified name instead of
self::
.While this is perfectly valid, the fully qualified name of
Certificate::TRIPLEDES_CBC
could just as well be replaced byself::TRIPLEDES_CBC
. Referencing local members withself::
assured the access will still work when the class is renamed, makes it perfectly clear that the member is in fact local and will usually be shorter.