1 | <?php |
||
7 | class HostsFileResolutionWriter implements HostnameResolutionWriter |
||
8 | { |
||
9 | /** |
||
10 | * @var ProcessRunner |
||
11 | */ |
||
12 | private $processRunner; |
||
13 | |||
14 | /** |
||
15 | * @param ProcessRunner $processRunner |
||
16 | */ |
||
17 | public function __construct(ProcessRunner $processRunner) |
||
21 | |||
22 | /** |
||
23 | * {@inheritdoc} |
||
24 | */ |
||
25 | public function write($hostname, $address) |
||
36 | |||
37 | /** |
||
38 | * Remove hostname reference from `/etc/hosts`. |
||
39 | * |
||
40 | * @param string $hostname |
||
41 | */ |
||
42 | private function removeHostname($hostname) |
||
60 | |||
61 | /** |
||
62 | * @return string |
||
63 | */ |
||
64 | private function getFilePath() |
||
68 | |||
69 | /** |
||
70 | * @param string $targetPath |
||
71 | * @param string $fileContents |
||
72 | */ |
||
73 | private function writeAsRoot($targetPath, $fileContents) |
||
80 | |||
81 | /** |
||
82 | * @param string $hostname |
||
83 | * @param string $address |
||
84 | * |
||
85 | * @return string |
||
86 | */ |
||
87 | private function getHostsFileResolutionLine($hostname, $address) |
||
91 | } |
||
92 |