Total Complexity | 10 |
Total Lines | 30 |
Duplicated Lines | 0 % |
Changes | 3 | ||
Bugs | 0 | Features | 1 |
1 | <?php |
||
19 | final class Meta extends AbstractAppMeta |
||
20 | { |
||
21 | /** |
||
22 | * @param string $name application name (Vendor\Project) |
||
23 | * @param string $context application context (prod-hal-app) |
||
24 | * @param string $appDir application directory |
||
25 | */ |
||
26 | public function __construct(string $name, string $context = 'app', string $appDir = '') |
||
27 | { |
||
28 | $this->name = $name; |
||
29 | $this->appDir = $appDir ?: $this->getAppDir($name); |
||
30 | $this->tmpDir = $this->appDir . DIRECTORY_SEPARATOR . 'var' . DIRECTORY_SEPARATOR . 'tmp' . DIRECTORY_SEPARATOR . $context; |
||
31 | if (! file_exists($this->tmpDir) && ! @mkdir($this->tmpDir, 0777, true) && ! is_dir($this->tmpDir)) { |
||
32 | throw new NotWritableException($this->tmpDir); |
||
33 | } |
||
34 | |||
35 | $this->logDir = $this->appDir . DIRECTORY_SEPARATOR . 'var' . DIRECTORY_SEPARATOR . 'log' . DIRECTORY_SEPARATOR . $context; |
||
36 | if (! file_exists($this->logDir) && ! @mkdir($this->logDir, 0777, true) && ! is_dir($this->logDir)) { |
||
37 | throw new NotWritableException($this->logDir); // @codeCoverageIgnore |
||
38 | } |
||
39 | } |
||
40 | |||
41 | private function getAppDir(string $name): string |
||
49 | } |
||
50 | } |
||
51 |