| Conditions | 6 |
| Paths | 1 |
| Total Lines | 23 |
| Code Lines | 18 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 20 |
| CRAP Score | 6 |
| Changes | 2 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 15 | 8 | public static function get() : array { |
|
| 16 | 1 | $fn = function (string $value, int $i, array $tokens) : ?array { |
|
| 17 | 8 | if (($start = \stripos($value, 'http://')) === false) { |
|
| 18 | 6 | if (($start = \stripos($value, 'https://')) === false) { |
|
| 19 | 3 | $start = \stripos($value, 'www.'); |
|
| 20 | } |
||
| 21 | } |
||
| 22 | 8 | if ($start !== false) { |
|
| 23 | 8 | $url = \rtrim(\substr($value, $start, \strcspn($value, '), ', $start)), '?+'); |
|
| 24 | 8 | $data = $i > 0 ? crawlers::getApp($tokens[--$i]) : []; |
|
| 25 | 8 | return \array_merge([ |
|
| 26 | 8 | 'type' => 'robot', |
|
| 27 | 8 | 'url' => $url, |
|
| 28 | 8 | 'category' => empty($data['app']) ? 'scraper' : 'crawler' |
|
| 29 | 8 | ], $data); |
|
| 30 | } |
||
| 31 | 3 | return null; |
|
| 32 | 1 | }; |
|
| 33 | 1 | return [ |
|
|
|
|||
| 34 | 1 | 'http://' => new props('any', $fn), |
|
| 35 | 1 | 'https://' => new props('any', $fn), |
|
| 36 | 1 | 'www.' => new props('start', $fn), |
|
| 37 | 1 | '.com' => new props('any', $fn), |
|
| 38 | 1 | ]; |
|
| 40 | } |