Total Complexity | 7 |
Total Lines | 67 |
Duplicated Lines | 0 % |
Coverage | 33.33% |
Changes | 3 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
22 | class Build |
||
23 | { |
||
24 | /** |
||
25 | * The name of the environment file. |
||
26 | * |
||
27 | * @var string |
||
28 | */ |
||
29 | private $environmentFile = '.env'; |
||
30 | |||
31 | /** |
||
32 | * Checks if the application is running from a Phar file. |
||
33 | * |
||
34 | * @return bool |
||
35 | */ |
||
36 | 39 | public function isRunning(): bool |
|
37 | { |
||
38 | 39 | return Phar::running() !== ''; |
|
39 | } |
||
40 | |||
41 | /** |
||
42 | * Returns the directory path from where the Phar is running. |
||
43 | * |
||
44 | * @return string |
||
45 | */ |
||
46 | public function getDirectoryPath(): string |
||
47 | { |
||
48 | return dirname($this->getPath()); |
||
49 | } |
||
50 | |||
51 | /** |
||
52 | * Returns the path from where the Phar is running. |
||
53 | * |
||
54 | * @return string |
||
55 | */ |
||
56 | public function getPath(): string |
||
57 | { |
||
58 | return Phar::running(false); |
||
59 | } |
||
60 | |||
61 | /** |
||
62 | * Returns the .env path with Phar running. |
||
63 | * |
||
64 | * @return string |
||
65 | */ |
||
66 | public function environmentFilePath(): string |
||
67 | { |
||
68 | return $this->getDirectoryPath().DIRECTORY_SEPARATOR.$this->environmentFile; |
||
69 | } |
||
70 | |||
71 | /** |
||
72 | * Checks if the build is running and there's an available environment file. |
||
73 | * |
||
74 | * @return bool |
||
75 | */ |
||
76 | 39 | public function shouldUseEnvironmentFile(): bool |
|
79 | } |
||
80 | |||
81 | /** |
||
82 | * The file for environment file. |
||
83 | * |
||
84 | * @return string |
||
85 | */ |
||
86 | public function environmentFile(): string |
||
89 | } |
||
90 | } |
||
91 |