Conditions | 3 |
Paths | 3 |
Total Lines | 19 |
Code Lines | 8 |
Lines | 0 |
Ratio | 0 % |
Tests | 8 |
CRAP Score | 3 |
Changes | 0 |
1 | <?php declare(strict_types=1); |
||
27 | 2 | public function getCommonPrefix(AbstractCG $group): string |
|
28 | { |
||
29 | 2 | $prefix = ''; |
|
30 | |||
31 | // Get shortest array |
||
32 | 2 | $minSize = min(strlen($this->string), strlen($group->string)); |
|
33 | |||
34 | // Iterate longest array |
||
35 | 2 | for ($i = 0; $i < $minSize; $i++) { |
|
36 | // On first mismatch - break |
||
37 | 2 | if ($this->string{$i} !== $group->string{$i}) { |
|
38 | 2 | break; |
|
39 | } |
||
40 | |||
41 | 2 | $prefix .= $this->string{$i}; |
|
42 | } |
||
43 | |||
44 | 2 | return $prefix; |
|
45 | } |
||
46 | |||
58 |