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