| Conditions | 2 |
| Paths | 2 |
| Total Lines | 8 |
| Code Lines | 4 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 0 |
| CRAP Score | 6 |
| Changes | 0 | ||
| 1 | <?php |
||
| 45 | private function replace(): void |
||
| 46 | { |
||
| 47 | foreach ($this->blocks as $key => $value) { |
||
| 48 | $this->content = preg_replace('/{\s?block \'?"?'.$key.'"?\'?\s?}(.*?){\s?\/block\s?}/is', $value, $this->content); |
||
| 49 | } |
||
| 50 | |||
| 51 | $this->content = preg_replace('/{\s?block \'?"?[\w]+"?\'?\s?}/is', '', $this->content); |
||
| 52 | $this->content = preg_replace('/{\s?\/block\s?}/is', '', $this->content); |
||
| 53 | } |
||
| 55 |
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: