| Conditions | 6 |
| Paths | 5 |
| Total Lines | 19 |
| Code Lines | 14 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 0 |
| CRAP Score | 42 |
| Changes | 1 | ||
| Bugs | 0 | Features | 1 |
| 1 | <?php |
||
| 34 | #[\Override] |
||
| 35 | public function get(string $name): object { |
||
| 36 | if (isset($this->instancesByFqcn[$name])) { |
||
| 37 | return $this->instancesByFqcn[$name]; |
||
| 38 | } |
||
| 39 | if (isset($this->instances[$name])) { |
||
| 40 | return $this->instances[$name]; |
||
| 41 | } |
||
| 42 | foreach ($this->getFqcnList() as $fqcn) { |
||
| 43 | $instance = \OCP\Server::get($fqcn); |
||
| 44 | $settings = $instance->getSettings(); |
||
| 45 | if ($fqcn === $name || $settings->id === $name) { |
||
| 46 | $instance->setAppConfig(\OCP\Server::get(\OCP\IAppConfig::class)); |
||
| 47 | $this->instances[$name] = $instance; |
||
| 48 | $this->instancesByFqcn[$fqcn] = $instance; |
||
| 49 | return $instance; |
||
| 50 | } |
||
| 51 | } |
||
| 52 | throw new InvalidProviderException("Provider <$name> does not exist"); |
||
| 53 | } |
||
| 55 |