| Total Complexity | 3 |
| Total Lines | 16 |
| Duplicated Lines | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 5 | class PhpUtils { |
||
| 6 | static private string $delimiter = '---'; |
||
| 7 | static private array $parsedFunctions = []; |
||
| 8 | |||
| 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 | } |
||
| 18 | |||
| 19 | public static function getParsedFunctions():array { |
||
| 21 | } |
||
| 22 | } |
||
| 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: