| Total Complexity | 6 |
| Total Lines | 56 |
| Duplicated Lines | 0 % |
| Coverage | 100% |
| Changes | 0 | ||
| 1 | <?php |
||
| 9 | abstract class AbstractSchemaValidatorFactory |
||
| 10 | { |
||
| 11 | /** |
||
| 12 | * @var FileLocatorInterface |
||
| 13 | */ |
||
| 14 | protected $fileLocator; |
||
| 15 | |||
| 16 | /** |
||
| 17 | * @var array |
||
| 18 | */ |
||
| 19 | protected $registeredSchemas; |
||
| 20 | |||
| 21 | /** |
||
| 22 | * @param FileLocatorInterface $fileLocator |
||
| 23 | */ |
||
| 24 | 9 | public function __construct(FileLocatorInterface $fileLocator) |
|
| 25 | { |
||
| 26 | 9 | $this->fileLocator = $fileLocator; |
|
| 27 | |||
| 28 | 9 | $this->registeredSchemas = []; |
|
| 29 | 9 | } |
|
| 30 | |||
| 31 | /** |
||
| 32 | * @param string $id |
||
| 33 | * @param string $schemaResourceLocation |
||
| 34 | * |
||
| 35 | * @throws \RuntimeException When schema with provided $id is already registered |
||
| 36 | */ |
||
| 37 | 8 | public function registerSchema(string $id, string $schemaResourceLocation): void |
|
| 38 | { |
||
| 39 | 8 | if ($this->hasSchema($id)) { |
|
| 40 | 1 | throw new \RuntimeException(sprintf('Schema with id "%s" already registered.', $id)); |
|
| 41 | } |
||
| 42 | |||
| 43 | 8 | $this->registeredSchemas[$id] = $schemaResourceLocation; |
|
| 44 | 8 | } |
|
| 45 | |||
| 46 | /** |
||
| 47 | * @param string $id |
||
| 48 | * |
||
| 49 | * @return bool |
||
| 50 | */ |
||
| 51 | 9 | public function hasSchema(string $id): bool |
|
| 54 | } |
||
| 55 | |||
| 56 | /** |
||
| 57 | * @param string $id |
||
| 58 | * |
||
| 59 | * @throws \RuntimeException When schema with id "%s" is not registered |
||
| 60 | */ |
||
| 61 | 8 | protected function assertHasSchema(string $id): void |
|
| 65 | } |
||
| 66 | 7 | } |
|
| 67 | } |
||
| 68 |