| Total Complexity | 8 |
| Total Lines | 44 |
| Duplicated Lines | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 13 | final class FromFileSchemaProvider implements SchemaProviderInterface |
||
| 14 | { |
||
| 15 | private string $file = ''; |
||
| 16 | private Aliases $aliases; |
||
| 17 | |||
| 18 | public function __construct(Aliases $aliases) |
||
| 19 | { |
||
| 20 | $this->aliases = $aliases; |
||
| 21 | } |
||
| 22 | |||
| 23 | public function withConfig(array $config): SchemaProviderInterface |
||
| 24 | { |
||
| 25 | $clone = clone $this; |
||
| 26 | // required option |
||
| 27 | $clone->file = $this->aliases->get($config['file']); |
||
| 28 | return $clone; |
||
| 29 | } |
||
| 30 | |||
| 31 | public function read(): ?array |
||
| 32 | { |
||
| 33 | if (!is_file($this->file)) { |
||
| 34 | return null; |
||
| 35 | } |
||
| 36 | return include $this->file; |
||
| 37 | } |
||
| 38 | |||
| 39 | public function write($schema): bool |
||
| 40 | { |
||
| 41 | return false; |
||
| 42 | } |
||
| 43 | |||
| 44 | public function clear(): bool |
||
| 45 | { |
||
| 46 | return false; |
||
| 47 | } |
||
| 48 | |||
| 49 | public function isWritable(): bool |
||
| 50 | { |
||
| 51 | return false; |
||
| 52 | } |
||
| 53 | |||
| 54 | public function isReadable(): bool |
||
| 57 | } |
||
| 58 | } |
||
| 59 |