| Conditions | 6 |
| Paths | 5 |
| Total Lines | 18 |
| Code Lines | 11 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 11 |
| CRAP Score | 6 |
| Changes | 0 | ||
| 1 | <?php |
||
| 61 | 10 | public static function serialize(array $links) |
|
| 62 | { |
||
| 63 | 10 | foreach ($links as $rel => $link) { |
|
| 64 | 10 | if (is_array($link)) { |
|
| 65 | 1 | foreach ($link as $i => $l) { |
|
| 66 | 1 | $link[$i] = $l instanceof self ? array_filter((array) $l) : ['href' => $l]; |
|
| 67 | } |
||
| 68 | 1 | $links[$rel] = $link; |
|
| 69 | } |
||
| 70 | 10 | if ($link instanceof self) { |
|
| 71 | 1 | $l = array_filter((array)$link); |
|
| 72 | 1 | $links[$rel] = $l; |
|
| 73 | } else { |
||
| 74 | 10 | $links[$rel] = ['href' => $link]; |
|
| 75 | } |
||
| 76 | } |
||
| 77 | |||
| 78 | 10 | return $links; |
|
| 79 | } |
||
| 81 |