| Total Complexity | 12 |
| Total Lines | 62 |
| Duplicated Lines | 0 % |
| Coverage | 96.43% |
| Changes | 0 | ||
| 1 | <?php |
||
| 5 | class ExtractExternalLinks |
||
| 6 | { |
||
| 7 | |||
| 8 | protected $id; |
||
| 9 | protected $dir; |
||
| 10 | protected $base; |
||
| 11 | protected $filter; |
||
| 12 | protected $filterType; |
||
| 13 | protected $external = []; |
||
| 14 | |||
| 15 | 3 | protected function __construct(string $id) |
|
| 24 | 3 | } |
|
| 25 | |||
| 26 | 3 | protected function filter($filename) |
|
| 29 | } |
||
| 30 | |||
| 31 | 3 | public static function scan(string $id) |
|
| 32 | { |
||
| 33 | 3 | $self = new self($id); |
|
| 34 | 3 | $self->scanDir(); |
|
| 35 | |||
| 36 | 3 | return $self->getExternals(); |
|
| 37 | } |
||
| 38 | |||
| 39 | 3 | protected function scanDir() |
|
| 48 | } |
||
| 49 | 3 | } |
|
| 50 | |||
| 51 | |||
| 52 | 2 | function harvestExternalLinks(string $content) |
|
|
|
|||
| 53 | { |
||
| 54 | 2 | $lines = explode(chr(10), $content); |
|
| 55 | |||
| 56 | 2 | foreach ($lines as $line) |
|
| 57 | { |
||
| 58 | 2 | if (strpos($line, $this->base) !== 0) { |
|
| 59 | 2 | $this->external[$line] = ($this->external[$line] ?? 0) + 1; |
|
| 60 | } |
||
| 61 | } |
||
| 62 | 2 | } |
|
| 63 | |||
| 64 | 3 | function getExternals() |
|
| 67 | } |
||
| 68 | } |
||
| 69 |
Adding explicit visibility (
private,protected, orpublic) is generally recommend to communicate to other developers how, and from where this method is intended to be used.