| Total Complexity | 7 |
| Total Lines | 69 |
| Duplicated Lines | 0 % |
| Coverage | 81.82% |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 9 | class VersionService |
||
| 10 | { |
||
| 11 | use CanUseDotPath; |
||
| 12 | |||
| 13 | private $default = VERSION_1_0; |
||
| 14 | |||
| 15 | private $version; |
||
| 16 | |||
| 17 | private $cache = []; |
||
| 18 | |||
| 19 | /** |
||
| 20 | * Create a new instance |
||
| 21 | * |
||
| 22 | * @param string|null $version The version of the JSON:API specification |
||
| 23 | * |
||
| 24 | * @return void |
||
| 25 | */ |
||
| 26 | 768 | public function __construct(string $version = null) |
|
| 29 | 768 | } |
|
| 30 | |||
| 31 | /** |
||
| 32 | * Set the version of the JSON:API specification |
||
| 33 | * |
||
| 34 | * @param string $version |
||
| 35 | * |
||
| 36 | * @return static |
||
| 37 | */ |
||
| 38 | 768 | public function setVersion(string $version) |
|
| 39 | { |
||
| 40 | 768 | $this->version = $version; |
|
| 41 | 768 | $this->createCache(); |
|
| 42 | |||
| 43 | 768 | return $this; |
|
| 44 | } |
||
| 45 | |||
| 46 | /** |
||
| 47 | * Get the version of the JSON:API specification |
||
| 48 | * |
||
| 49 | * @return string |
||
| 50 | */ |
||
| 51 | public function getVersion(): string |
||
| 52 | { |
||
| 53 | return $this->version; |
||
| 54 | } |
||
| 55 | |||
| 56 | 441 | public function getRule(string $path) |
|
| 57 | { |
||
| 58 | 441 | return $this->retrieve($path, $this->cache); |
|
| 59 | } |
||
| 60 | |||
| 61 | 768 | private function createCache(): void |
|
| 78 | 768 | } |
|
| 79 | } |
||
| 80 |