1 | <?php |
||
12 | class WorkingDirectory |
||
13 | { |
||
14 | const DRAFT_CONTENT = <<<DRAFT |
||
15 | DATABASE_USER=[user] |
||
16 | DATABASE_PASSWORD=[password] |
||
17 | DATABASE_HOST=[host] |
||
18 | DATABASE_PORT=[port] |
||
19 | DATABASE_NAME=[database] |
||
20 | PROVISIONING_TABLE=changelog_database_deployments |
||
21 | PROVISIONING_TABLE_CANDIDATE_NUMBER_COLUMN=deploy_script_number |
||
22 | DRAFT; |
||
23 | const FILE_SUFFIX = '.env'; |
||
24 | |||
25 | /** @var string */ |
||
26 | private $currentDirectory; |
||
27 | |||
28 | /** @var Filesystem */ |
||
29 | private $filesystem; |
||
30 | |||
31 | /** @var string */ |
||
32 | private $currentDirectoryAbsolute; |
||
33 | |||
34 | /** @var EnvironmentLoaderInterface */ |
||
35 | private $environmentLoader; |
||
36 | |||
37 | |||
38 | /** |
||
39 | * @param string $currentDirectory |
||
40 | * @param CandidatesFinder $finder |
||
41 | * @param Filesystem $filesystem |
||
42 | * @param EnvironmentLoaderInterface $environmentLoader |
||
43 | */ |
||
44 | public function __construct($currentDirectory, CandidatesFinder $finder, Filesystem $filesystem, EnvironmentLoaderInterface $environmentLoader) |
||
52 | |||
53 | /** |
||
54 | * @param string $newPath |
||
55 | * @return WorkingDirectory |
||
56 | */ |
||
57 | public function cd($newPath) |
||
61 | |||
62 | /** |
||
63 | * @return void |
||
64 | */ |
||
65 | public function createEnvironmentFile() |
||
73 | |||
74 | /** |
||
75 | * @return void |
||
76 | */ |
||
77 | public function loadEnvironment() |
||
81 | |||
82 | /** |
||
83 | * @return Finder |
||
84 | */ |
||
85 | public function getCandidates() |
||
89 | |||
90 | /** |
||
91 | * @return string |
||
92 | */ |
||
93 | public function getCurrentDirectoryAbsolute(): string |
||
97 | |||
98 | /** |
||
99 | * @return string |
||
100 | */ |
||
101 | public function __toString() |
||
105 | |||
106 | /** |
||
107 | * @param string $path |
||
108 | * @return string |
||
109 | */ |
||
110 | private function buildAbsolutePath($path) |
||
120 | } |
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: