| Total Complexity | 7 |
| Total Lines | 105 |
| Duplicated Lines | 0 % |
| Coverage | 100% |
| Changes | 0 | ||
| 1 | <?php |
||
| 5 | abstract class Identifier |
||
| 6 | { |
||
| 7 | /** |
||
| 8 | * The query string. |
||
| 9 | * |
||
| 10 | * @var string |
||
| 11 | */ |
||
| 12 | private $queryString; |
||
| 13 | |||
| 14 | /** |
||
| 15 | * The regex matches. |
||
| 16 | * |
||
| 17 | * @var array |
||
| 18 | */ |
||
| 19 | protected $matches; |
||
| 20 | |||
| 21 | /** |
||
| 22 | * The regex to identify an identifier. |
||
| 23 | * |
||
| 24 | * @var string |
||
| 25 | */ |
||
| 26 | protected $regex; |
||
| 27 | |||
| 28 | /** |
||
| 29 | * Array containing API resources to be fetched. |
||
| 30 | * |
||
| 31 | * @var array |
||
| 32 | */ |
||
| 33 | protected $resources; |
||
| 34 | |||
| 35 | /** |
||
| 36 | * Base resource webpage URL. |
||
| 37 | * |
||
| 38 | * @var string |
||
| 39 | */ |
||
| 40 | protected $baseUrl; |
||
| 41 | 28 | ||
| 42 | /** |
||
| 43 | 28 | * Identifier constructor. |
|
| 44 | 28 | * |
|
| 45 | * @param string $queryString |
||
| 46 | */ |
||
| 47 | public function __construct(string $queryString) |
||
| 48 | { |
||
| 49 | $this->queryString = $queryString; |
||
| 50 | } |
||
| 51 | |||
| 52 | /** |
||
| 53 | 24 | * Does the query contain a valid Identifier? |
|
| 54 | * |
||
| 55 | 24 | * @return bool |
|
| 56 | 24 | */ |
|
| 57 | public function isValid(): bool |
||
| 60 | } |
||
| 61 | |||
| 62 | /** |
||
| 63 | 1 | * Resources getter. |
|
| 64 | * |
||
| 65 | * @return array |
||
| 66 | */ |
||
| 67 | public function getRelatedResources(): array |
||
| 70 | } |
||
| 71 | 24 | ||
| 72 | /** |
||
| 73 | 24 | * Complementary Resources getter. |
|
| 74 | * |
||
| 75 | * @return array |
||
| 76 | */ |
||
| 77 | public function getComplementaryResources(): array |
||
| 80 | } |
||
| 81 | 3 | ||
| 82 | /** |
||
| 83 | 3 | * Return URL to the identifier's publication website. |
|
| 84 | * |
||
| 85 | * @return string |
||
| 86 | */ |
||
| 87 | public function getUrl() |
||
| 88 | { |
||
| 89 | return $this->baseUrl.$this->getQueryString(); |
||
| 90 | } |
||
| 91 | 4 | ||
| 92 | /** |
||
| 93 | 4 | * Class to String. |
|
| 94 | * |
||
| 95 | * @return string |
||
| 96 | */ |
||
| 97 | public function __toString(): string |
||
| 98 | { |
||
| 99 | return $this->getQueryString(); |
||
| 100 | } |
||
| 101 | 9 | ||
| 102 | /** |
||
| 103 | 9 | * QueryString getter. |
|
| 104 | * |
||
| 105 | * @return string |
||
| 106 | */ |
||
| 107 | public function getQueryString() |
||
| 110 | } |
||
| 111 | } |
||
| 112 |