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 Variable |
||
38 | */ |
||
39 | private $subject; |
||
40 | |||
41 | /** |
||
42 | * @var Schema |
||
43 | */ |
||
44 | private $schema; |
||
45 | |||
46 | /** |
||
47 | * @var array |
||
48 | */ |
||
49 | private $arguments; |
||
50 | |||
51 | /** |
||
52 | * @param string $mode |
||
53 | */ |
||
54 | 77 | public function __construct($mode, Variable $subject, Schema $schema, array $arguments) { |
|
62 | |||
63 | /** |
||
64 | * @return string |
||
65 | */ |
||
66 | 66 | public function mode() { |
|
67 | 66 | return $this->mode; |
|
68 | } |
||
69 | |||
70 | /** |
||
71 | * Definition of the entities this rule was defined for. |
||
72 | * |
||
73 | * @return Variable |
||
74 | */ |
||
75 | 69 | public function subject() { |
|
78 | |||
79 | /** |
||
80 | * Definition of the entities this rule needs to be checked on. |
||
81 | * |
||
82 | * In the default case the rule needs to be checked on every entity that |
||
83 | * is not subject() if the mode is MODE_ONLY_CAN, as this really says |
||
84 | * something about the other entities. |
||
85 | * |
||
86 | * @return Variable |
||
87 | */ |
||
88 | 51 | public function checked_on() { |
|
97 | |||
98 | /** |
||
99 | * Get all variables referenced by the rule. |
||
100 | * |
||
101 | * @return Vars\Variable[] |
||
102 | */ |
||
103 | 18 | public function variables() { |
|
112 | |||
113 | /** |
||
114 | * Get the schema that was used for the rule. |
||
115 | * |
||
116 | * @return Schema |
||
117 | */ |
||
118 | 18 | public function schema() { |
|
121 | |||
122 | /** |
||
123 | * Pretty print the rule. |
||
124 | * |
||
125 | * @return string |
||
126 | */ |
||
127 | 15 | public function pprint() { |
|
140 | |||
141 | /** |
||
142 | * Compile the rule to SQL. |
||
143 | * |
||
144 | * @param Query $query |
||
145 | * @return Statement |
||
146 | */ |
||
147 | 49 | public function compile(Query $query) { |
|
150 | |||
151 | /** |
||
152 | * Turn a query result into a violation. |
||
153 | * |
||
154 | * @param array $row |
||
155 | * @return \Lechimp\Dicto\Analysis\Violation |
||
156 | */ |
||
157 | 2 | public function to_violation(array $row) { |
|
160 | |||
161 | /** |
||
162 | * Get the argument at the index. |
||
163 | * |
||
164 | * @throws \OutOfRangeException |
||
165 | * @param int $index |
||
166 | * @return mixed |
||
167 | */ |
||
168 | 61 | public function argument($index) { |
|
174 | |||
175 | /** |
||
176 | * Get all arguments. |
||
177 | * |
||
178 | * @return array |
||
179 | */ |
||
180 | 3 | public function arguments() { |
|
183 | } |
||
184 | |||
185 |
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.