| Total Complexity | 9 |
| Total Lines | 43 |
| Duplicated Lines | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 9 | class DirectoryPath |
||
| 10 | { |
||
| 11 | /** @var string */ |
||
| 12 | private $path; |
||
| 13 | |||
| 14 | /** @throws ConfigurationException */ |
||
| 15 | public function __construct(string $path) |
||
| 16 | { |
||
| 17 | $this->ensureDirectoryExists($path); |
||
| 18 | $this->path = $path; |
||
| 19 | } |
||
| 20 | |||
| 21 | public function asString(): string |
||
| 22 | { |
||
| 23 | return $this->path; |
||
| 24 | } |
||
| 25 | |||
| 26 | /** @throws ConfigurationException */ |
||
| 27 | public static function createAndGetInstance(string $path): self |
||
| 28 | { |
||
| 29 | if (!is_dir($path)) { |
||
| 30 | $created = mkdir($path); |
||
| 31 | if (!$created) { |
||
| 32 | throw new RuntimeException('Could not create directory ' . $path); |
||
| 33 | } |
||
| 34 | } |
||
| 35 | return new self($path); |
||
| 36 | } |
||
| 37 | |||
| 38 | /** @throws ConfigurationException */ |
||
| 39 | public static function createAbsoluteOrRelativeToCodeceptionDir(string $path): self |
||
| 45 | } |
||
| 46 | |||
| 47 | /** @throws ConfigurationException */ |
||
| 48 | private function ensureDirectoryExists(string $path): void |
||
| 52 | } |
||
| 53 | } |
||
| 54 | } |
||
| 55 |