1 | <?php |
||
13 | class WorkingDirectory |
||
14 | { |
||
15 | const MANDATORY_ENV_VARIABLES = [ |
||
16 | 'DATABASE_USER', |
||
17 | 'DATABASE_PASSWORD', |
||
18 | 'DATABASE_NAME', |
||
19 | 'DATABASE_PORT', |
||
20 | 'DATABASE_HOST', |
||
21 | 'PROVISIONING_TABLE', |
||
22 | 'PROVISIONING_TABLE_CANDIDATE_NUMBER_COLUMN', |
||
23 | ]; |
||
24 | |||
25 | /** @var string */ |
||
26 | private $currentDirectory; |
||
27 | |||
28 | /** @var Filesystem */ |
||
29 | private $filesystem; |
||
30 | |||
31 | /** @var string */ |
||
32 | private $currentDirectoryAbsolute; |
||
33 | |||
34 | |||
35 | |||
36 | /** |
||
37 | * @param $currentDirectory |
||
38 | * @param CandidatesFinder $finder |
||
39 | */ |
||
40 | public function __construct($currentDirectory, CandidatesFinder $finder) |
||
47 | |||
48 | |||
49 | |||
50 | /** |
||
51 | * @param $newPath |
||
52 | * @return WorkingDirectory |
||
53 | */ |
||
54 | public function cd($newPath) |
||
58 | |||
59 | |||
60 | |||
61 | public function touchDotEnv() |
||
76 | |||
77 | |||
78 | |||
79 | /** |
||
80 | * @return string |
||
81 | */ |
||
82 | public function getDotEnvFilepath() |
||
86 | |||
87 | |||
88 | |||
89 | public function loadDotEnv() |
||
104 | |||
105 | |||
106 | |||
107 | /** |
||
108 | * @return Finder |
||
109 | */ |
||
110 | public function getCandidates() |
||
114 | |||
115 | |||
116 | |||
117 | /** |
||
118 | * @param string $path |
||
119 | * @return string |
||
120 | */ |
||
121 | private function buildAbsolutePath($path) |
||
131 | } |
In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:
Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion: