Conditions | 4 |
Paths | 4 |
Total Lines | 25 |
Code Lines | 14 |
Lines | 0 |
Ratio | 0 % |
Tests | 0 |
CRAP Score | 20 |
Changes | 3 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
29 | public function writeCache() |
||
30 | { |
||
31 | $all = $this->gateway->getAll(); |
||
32 | |||
33 | $content = "use \\BrainExe\\Core\\EventDispatcher\\AbstractEvent;\n\nreturn function(AbstractEvent \$event, \$eventName, \$listener) {\n"; |
||
34 | foreach ($all as $entity) { |
||
35 | if (!$entity->compiledCondition) { |
||
36 | continue; |
||
37 | } |
||
38 | |||
39 | if (!$entity->enabled) { |
||
40 | continue; |
||
41 | } |
||
42 | |||
43 | $content .= sprintf( |
||
44 | "\t\t\$entity = %s;\n\t\tif (%s) {\n\t\t\tyield \$entity;\n\t\t}\n", |
||
45 | var_export($entity, true), |
||
46 | $entity->compiledCondition |
||
47 | ); |
||
48 | } |
||
49 | |||
50 | $content .= "};"; |
||
51 | |||
52 | $this->dumpCacheFile(self::CACHE_FILE, $content); |
||
53 | } |
||
54 | } |
||
55 |
In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:
Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion: