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 Filesystem */ |
||
26 | private $filesystem; |
||
27 | |||
28 | /** @var string */ |
||
29 | private $currentDirectoryAbsolute; |
||
30 | |||
31 | /** @var EnvironmentLoaderInterface */ |
||
32 | private $environmentLoader; |
||
33 | |||
34 | /** @var CandidatesFinder */ |
||
35 | private $finder; |
||
36 | |||
37 | |||
38 | /** |
||
39 | * @param string $currentDirectory |
||
40 | * @param CandidatesFinder $finder |
||
41 | * @param Filesystem $filesystem |
||
42 | * @param EnvironmentLoaderInterface $environmentLoader |
||
43 | */ |
||
44 | 7 | public function __construct($currentDirectory, CandidatesFinder $finder, Filesystem $filesystem, EnvironmentLoaderInterface $environmentLoader) |
|
51 | |||
52 | /** |
||
53 | * @param string $newPath |
||
54 | * @return WorkingDirectory |
||
55 | */ |
||
56 | 1 | public function cd($newPath) |
|
60 | |||
61 | /** |
||
62 | * @return void |
||
63 | */ |
||
64 | 1 | public function createEnvironmentFile() |
|
72 | |||
73 | /** |
||
74 | * @return void |
||
75 | */ |
||
76 | 1 | public function loadEnvironment() |
|
80 | |||
81 | /** |
||
82 | * @return Finder |
||
83 | */ |
||
84 | 1 | public function getCandidates() |
|
88 | |||
89 | /** |
||
90 | * @return string |
||
91 | */ |
||
92 | 3 | public function getCurrentDirectoryAbsolute() |
|
96 | |||
97 | /** |
||
98 | * @return string |
||
99 | */ |
||
100 | 1 | public function __toString() |
|
104 | |||
105 | /** |
||
106 | * @param string $path |
||
107 | * @return string |
||
108 | */ |
||
109 | 7 | private function buildAbsolutePath($path) |
|
119 | } |
||
120 |