@@ -80,7 +80,8 @@ discard block |
||
| 80 | 80 | $errors = $this->registerReaders($this->getDefaultReaders()); |
| 81 | 81 | $this->registerCompositeReaders($this->getDefaultCompositeReaders(), $this->readers); |
| 82 | 82 | |
| 83 | - if (\count($this->readers) === 0) { |
|
| 83 | + if (\count($this->readers) === 0) |
|
| 84 | + { |
|
| 84 | 85 | throw $this->bootError($errors); |
| 85 | 86 | } |
| 86 | 87 | } |
@@ -90,13 +91,15 @@ discard block |
||
| 90 | 91 | */ |
| 91 | 92 | public function get(string $name = self::DEFAULT_READER): ReaderInterface |
| 92 | 93 | { |
| 93 | - if ($name === self::DEFAULT_READER) { |
|
| 94 | + if ($name === self::DEFAULT_READER) |
|
| 95 | + { |
|
| 94 | 96 | $name = $this->default; |
| 95 | 97 | } |
| 96 | 98 | |
| 97 | 99 | $reader = $this->readers[$name] ?? null; |
| 98 | 100 | |
| 99 | - if ($reader === null) { |
|
| 101 | + if ($reader === null) |
|
| 102 | + { |
|
| 100 | 103 | throw new NotFoundException(\sprintf(self::ERROR_DRIVER_NOT_FOUND, $name)); |
| 101 | 104 | } |
| 102 | 105 | |
@@ -127,7 +130,8 @@ discard block |
||
| 127 | 130 | { |
| 128 | 131 | $messages = []; |
| 129 | 132 | |
| 130 | - foreach ($errors as $reader => $message) { |
|
| 133 | + foreach ($errors as $reader => $message) |
|
| 134 | + { |
|
| 131 | 135 | $messages[] = \sprintf(' - %s: %s', $reader, $message); |
| 132 | 136 | } |
| 133 | 137 | |
@@ -141,7 +145,8 @@ discard block |
||
| 141 | 145 | */ |
| 142 | 146 | private function registerCustomReaders(iterable $readers): void |
| 143 | 147 | { |
| 144 | - foreach ($readers as $name => $reader) { |
|
| 148 | + foreach ($readers as $name => $reader) |
|
| 149 | + { |
|
| 145 | 150 | $name = \is_string($name) ? $name : \get_class($reader); |
| 146 | 151 | |
| 147 | 152 | assert(is_subclass_of($name, ReaderInterface::class), 'Precondition failed'); |
@@ -157,7 +162,8 @@ discard block |
||
| 157 | 162 | */ |
| 158 | 163 | private function registerCompositeReaders(iterable $readers, array $registered): void |
| 159 | 164 | { |
| 160 | - if (\count($registered) !== 0) { |
|
| 165 | + if (\count($registered) !== 0) |
|
| 166 | + { |
|
| 161 | 167 | $this->registerReaders($readers, [$registered]); |
| 162 | 168 | } |
| 163 | 169 | } |
@@ -171,14 +177,19 @@ discard block |
||
| 171 | 177 | { |
| 172 | 178 | $errors = []; |
| 173 | 179 | |
| 174 | - foreach ($readers as $reader) { |
|
| 175 | - try { |
|
| 176 | - if (isset($this->readers[$reader])) { |
|
| 180 | + foreach ($readers as $reader) |
|
| 181 | + { |
|
| 182 | + try |
|
| 183 | + { |
|
| 184 | + if (isset($this->readers[$reader])) |
|
| 185 | + { |
|
| 177 | 186 | continue; |
| 178 | 187 | } |
| 179 | 188 | |
| 180 | 189 | $this->readers[$reader] = new $reader(...\array_values($arguments)); |
| 181 | - } catch (InitializationException $e) { |
|
| 190 | + } |
|
| 191 | + catch (InitializationException $e) |
|
| 192 | + { |
|
| 182 | 193 | $errors[$reader] = $e->getMessage(); |
| 183 | 194 | } |
| 184 | 195 | } |