Conditions | 4 |
Paths | 5 |
Total Lines | 20 |
Code Lines | 10 |
Lines | 0 |
Ratio | 0 % |
Changes | 0 |
1 | <?php |
||
12 | public static function escapeWholeTextPattern($needle) |
||
13 | { |
||
14 | $escapedNeedle = self::escapeRegularPattern($needle); |
||
15 | $splittedNeedle = Strings::split($escapedNeedle); |
||
16 | |||
17 | $final = ''; |
||
18 | |||
19 | foreach ($splittedNeedle as $index => $letter) { |
||
20 | if ($index === self::getFirstBounduaryPosition($splittedNeedle)) { |
||
21 | $final .= "\\b"; |
||
22 | } |
||
23 | |||
24 | $final .= $letter; |
||
25 | |||
26 | if ($index === self::getLastBounduaryPosition($splittedNeedle)) { |
||
27 | $final .= "\\b"; |
||
28 | } |
||
29 | } |
||
30 | |||
31 | return $final; |
||
32 | } |
||
88 |
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: