Conditions | 2 |
Paths | 2 |
Total Lines | 8 |
Code Lines | 6 |
Lines | 0 |
Ratio | 0 % |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
9 | public static function parseFile(string $filename, string $extension): array { |
||
10 | $pattern = '/' . self::$delimiter . '(.+?)'. self::$delimiter . '(.+?)' . self::$delimiter . 'end' . self::$delimiter . '/s'; |
||
11 | $templateString = \file_get_contents($filename . '.' . $extension, true); |
||
12 | \preg_match_all($pattern, $templateString, $templateArray); |
||
13 | for($i=0;$i<count($templateArray[0]);$i++){ |
||
|
|||
14 | self::$parsedFunctions[$templateArray[1][$i]] = $templateArray[2][$i]; |
||
15 | } |
||
16 | return $templateArray; |
||
17 | } |
||
24 |
If the size of the collection does not change during the iteration, it is generally a good practice to compute it beforehand, and not on each iteration: