| Conditions | 4 |
| Paths | 4 |
| Total Lines | 24 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
| 1 | <?php |
||
| 48 | public function loadTenants() { |
||
| 49 | if (!file_exists($this->path)) { |
||
| 50 | // TODO: Throw an error or log or something |
||
| 51 | return []; |
||
| 52 | } |
||
| 53 | |||
| 54 | /* @var $files SplFileInfo[] */ |
||
| 55 | $files = $this->finder |
||
| 56 | ->files() |
||
| 57 | ->in($this->path) |
||
| 58 | ->name($this->file_pattern); |
||
| 59 | |||
| 60 | $tenants = []; |
||
| 61 | |||
| 62 | foreach ($files as $file) { |
||
| 63 | if (!preg_match($this->file_pattern, $file->getFilename(), $matches)) { |
||
| 64 | throw new \RuntimeException(sprintf('Could not detect tenant key based on filename "%s"', $file->getFilename())); |
||
| 65 | } |
||
| 66 | |||
| 67 | $tenants[$matches['tenant']] = new Tenant($matches['tenant']); |
||
| 68 | } |
||
| 69 | |||
| 70 | return $tenants; |
||
| 71 | } |
||
| 72 | |||
| 106 |