| Conditions | 2 |
| Paths | 1 |
| Total Lines | 22 |
| Code Lines | 12 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 13 |
| CRAP Score | 2 |
| Changes | 2 | ||
| Bugs | 0 | Features | 2 |
| 1 | <?php |
||
| 19 | public function wrapImgInFigure($content) |
||
| 20 | { |
||
| 21 | 1 | $callback = function ($matches) { |
|
| 22 | 1 | $img = $matches[1]; |
|
| 23 | 1 | $pattern = '/class="([^"]+)"/'; |
|
| 24 | |||
| 25 | 1 | preg_match($pattern, $img, $matches); |
|
| 26 | |||
| 27 | 1 | $classes = $matches[1]; |
|
| 28 | 1 | $class = ''; |
|
| 29 | |||
| 30 | 1 | if (isset($classes)) { |
|
| 31 | 1 | $class = ' class="' . $classes . '"'; |
|
| 32 | 1 | } |
|
| 33 | |||
| 34 | 1 | return '<figure' . $class . '>' . $img . '</figure>'; |
|
| 35 | 1 | }; |
|
| 36 | |||
| 37 | 1 | $content = preg_replace_callback('/(<a .*?><img.*?><\/a>|<img.*?>)/s', $callback, $content); |
|
| 38 | |||
| 39 | 1 | return $content; |
|
| 40 | } |
||
| 41 | |||
| 71 |
This check looks for the generic type
arrayas a return type and suggests a more specific type. This type is inferred from the actual code.