Conditions | 3 |
Paths | 3 |
Total Lines | 14 |
Code Lines | 7 |
Lines | 0 |
Ratio | 0 % |
Tests | 0 |
CRAP Score | 12 |
Changes | 2 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
41 | public function getAlternativeLinks() : array { |
||
42 | |||
43 | $result = []; |
||
44 | |||
45 | foreach($this->_raw->header as $line) { |
||
46 | $matches = []; |
||
47 | preg_match_all('/^link: <(.*)>;rel="alternate"$/', $line, $matches); |
||
48 | |||
49 | if(isset($matches[1][0])) { |
||
50 | $result[] = $matches[1][0]; |
||
51 | } |
||
52 | } |
||
53 | |||
54 | return $result; |
||
55 | } |
||
56 | } |
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: