1 | <?php |
||
20 | class Rule extends Definition { |
||
21 | const MODE_CANNOT = "CANNOT"; |
||
22 | const MODE_MUST = "MUST"; |
||
23 | const MODE_ONLY_CAN = "ONLY_CAN"; |
||
24 | |||
25 | static $modes = array |
||
|
|||
26 | ( Rule::MODE_CANNOT |
||
27 | , Rule::MODE_MUST |
||
28 | , Rule::MODE_ONLY_CAN |
||
29 | ); |
||
30 | |||
31 | /** |
||
32 | * @var string |
||
33 | */ |
||
34 | private $mode; |
||
35 | |||
36 | /** |
||
37 | * @var Vars\Variable |
||
38 | */ |
||
39 | private $subject; |
||
40 | |||
41 | /** |
||
42 | * @var R\Schema |
||
43 | */ |
||
44 | private $schema; |
||
45 | |||
46 | /** |
||
47 | * @var array |
||
48 | */ |
||
49 | private $arguments; |
||
50 | |||
51 | /** |
||
52 | * @param string $mode |
||
53 | */ |
||
54 | 241 | public function __construct($mode, Variable $subject, Schema $schema, array $arguments) { |
|
62 | |||
63 | public function explain($explanation) { |
||
68 | |||
69 | /** |
||
70 | * @return string |
||
71 | */ |
||
72 | 53 | public function mode() { |
|
75 | |||
76 | /** |
||
77 | * Definition of the entities this rule was defined for. |
||
78 | * |
||
79 | * @return Variable |
||
80 | */ |
||
81 | 56 | public function subject() { |
|
84 | |||
85 | /** |
||
86 | * Definition of the entities this rule needs to be checked on. |
||
87 | * |
||
88 | * In the default case the rule needs to be checked on every entity that |
||
89 | * is not subject() if the mode is MODE_ONLY_CAN, as this really says |
||
90 | * something about the other entities. |
||
91 | * |
||
92 | * @return Variable |
||
93 | */ |
||
94 | 50 | public function checked_on() { |
|
104 | |||
105 | /** |
||
106 | * Get all variables referenced by the rule. |
||
107 | * |
||
108 | * @return Vars\Variable[] |
||
109 | */ |
||
110 | 5 | public function variables() { |
|
119 | |||
120 | /** |
||
121 | * Get the schema that was used for the rule. |
||
122 | * |
||
123 | * @return Schema |
||
124 | */ |
||
125 | 3 | public function schema() { |
|
128 | |||
129 | /** |
||
130 | * Pretty print the rule. |
||
131 | * |
||
132 | * @return string |
||
133 | */ |
||
134 | 3 | public function pprint() { |
|
147 | |||
148 | /** |
||
149 | * Compile the rule to SQL. |
||
150 | * |
||
151 | * @param Query $query |
||
152 | * @return Statement |
||
153 | */ |
||
154 | 48 | public function compile(Query $query) { |
|
157 | |||
158 | /** |
||
159 | * Turn a query result into a violation. |
||
160 | * |
||
161 | * @param array $row |
||
162 | * @param string $file_source |
||
163 | * @return Violation |
||
164 | */ |
||
165 | 2 | public function to_violation(array $row, array $file_source) { |
|
168 | |||
169 | /** |
||
170 | * Get the argument at the index. |
||
171 | * |
||
172 | * @throws \OutOfRangeException |
||
173 | * @param int $index |
||
174 | * @return mixed |
||
175 | */ |
||
176 | 51 | public function argument($index) { |
|
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.