| Conditions | 6 |
| Paths | 5 |
| Total Lines | 28 |
| Code Lines | 18 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 19 |
| CRAP Score | 6 |
| Changes | 0 | ||
| 1 | <?php |
||
| 15 | 3 | protected function optimizeStream() |
|
| 16 | { |
||
| 17 | 3 | while ($this->stream->skipTo(T_CONSTANT_ENCAPSED_STRING)) |
|
| 18 | { |
||
| 19 | 3 | $offset = $this->stream->key(); |
|
| 20 | 3 | $left = $this->stream->currentText(); |
|
| 21 | 3 | $this->stream->next(); |
|
| 22 | 3 | $this->stream->skipNoise(); |
|
| 23 | 3 | if (!$this->stream->is('.')) |
|
| 24 | { |
||
| 25 | 3 | continue; |
|
| 26 | } |
||
| 27 | 3 | $this->stream->next(); |
|
| 28 | 3 | $this->stream->skipNoise(); |
|
| 29 | 3 | $right = $this->stream->currentText(); |
|
| 30 | 3 | if (!$this->stream->is(T_CONSTANT_ENCAPSED_STRING) || $left[0] !== $right[0]) |
|
| 31 | { |
||
| 32 | 1 | continue; |
|
| 33 | } |
||
| 34 | 2 | $this->stream->replace([T_CONSTANT_ENCAPSED_STRING, substr($left, 0, -1) . substr($right, 1)]); |
|
| 35 | 2 | $i = $this->stream->key(); |
|
| 36 | 2 | $this->stream->seek($i - 1); |
|
| 37 | 2 | while (--$i >= $offset) |
|
| 38 | { |
||
| 39 | 2 | unset($this->stream[$i]); |
|
| 40 | } |
||
| 41 | } |
||
| 42 | } |
||
| 43 | } |