1 | <?php |
||
19 | class Rule extends Definition { |
||
20 | const MODE_CANNOT = "CANNOT"; |
||
21 | const MODE_MUST = "MUST"; |
||
22 | const MODE_ONLY_CAN = "ONLY_CAN"; |
||
23 | |||
24 | static $modes = array |
||
|
|||
25 | ( Rule::MODE_CANNOT |
||
26 | , Rule::MODE_MUST |
||
27 | , Rule::MODE_ONLY_CAN |
||
28 | ); |
||
29 | |||
30 | /** |
||
31 | * @var string |
||
32 | */ |
||
33 | private $mode; |
||
34 | |||
35 | /** |
||
36 | * @var Variable |
||
37 | */ |
||
38 | private $subject; |
||
39 | |||
40 | /** |
||
41 | * @var Schema |
||
42 | */ |
||
43 | private $schema; |
||
44 | |||
45 | /** |
||
46 | * @var array |
||
47 | */ |
||
48 | private $arguments; |
||
49 | |||
50 | /** |
||
51 | * @param string $mode |
||
52 | */ |
||
53 | 46 | public function __construct($mode, Variable $subject, Schema $schema, array $arguments) { |
|
61 | |||
62 | /** |
||
63 | * @return string |
||
64 | */ |
||
65 | 37 | public function mode() { |
|
68 | |||
69 | /** |
||
70 | * Definition of the entities this rule was defined for. |
||
71 | * |
||
72 | * @return Variable |
||
73 | */ |
||
74 | 40 | public function subject() { |
|
77 | |||
78 | /** |
||
79 | * Definition of the entities this rule needs to be checked on. |
||
80 | * |
||
81 | * In the default case the rule needs to be checked on every entity that |
||
82 | * is not subject() if the mode is MODE_ONLY_CAN, as this really says |
||
83 | * something about the other entities. |
||
84 | * |
||
85 | * @return Variable |
||
86 | */ |
||
87 | 22 | public function checked_on() { |
|
96 | |||
97 | /** |
||
98 | * Get all variables referenced by the rule. |
||
99 | * |
||
100 | * @return Vars\Variable[] |
||
101 | */ |
||
102 | 35 | public function variables() { |
|
111 | |||
112 | /** |
||
113 | * Get the schema that was used for the rule. |
||
114 | * |
||
115 | * @return Schema |
||
116 | */ |
||
117 | 35 | public function schema() { |
|
120 | |||
121 | /** |
||
122 | * Pretty print the rule. |
||
123 | * |
||
124 | * @return string |
||
125 | */ |
||
126 | 32 | public function pprint() { |
|
139 | |||
140 | /** |
||
141 | * Compile the rule to SQL. |
||
142 | * |
||
143 | * @param Index $index |
||
144 | * @return Query |
||
145 | */ |
||
146 | 20 | public function compile(Index $index) { |
|
149 | |||
150 | /** |
||
151 | * Turn a query result into a violation. |
||
152 | * |
||
153 | * @param array $row |
||
154 | * @return \Lechimp\Dicto\Analysis\Violation |
||
155 | */ |
||
156 | 7 | public function to_violation(array $row) { |
|
159 | |||
160 | /** |
||
161 | * Get the argument at the index. |
||
162 | * |
||
163 | * @throws \OutOfRangeException |
||
164 | * @param int $index |
||
165 | * @return mixed |
||
166 | */ |
||
167 | 32 | public function argument($index) { |
|
173 | |||
174 | /** |
||
175 | * Get all arguments. |
||
176 | * |
||
177 | * @return array |
||
178 | */ |
||
179 | 3 | public function arguments() { |
|
182 | } |
||
183 | |||
184 |
The PSR-2 coding standard requires that all properties in a class have their visibility explicitly declared. If you declare a property using
the property is implicitly global.
To learn more about the PSR-2, please see the PHP-FIG site on the PSR-2.