| Total Complexity | 5 |
| Total Lines | 48 |
| Duplicated Lines | 0 % |
| Changes | 0 | ||
| 1 | <?php declare(strict_types=1); |
||
| 10 | class MachineIp implements LazyEnvironmentValue |
||
| 11 | { |
||
| 12 | /** |
||
| 13 | * @var IP |
||
| 14 | */ |
||
| 15 | private $ip; |
||
| 16 | |||
| 17 | public static function fromMachine(ProcessRunner $processRunner): self |
||
| 18 | { |
||
| 19 | $process = Process::fromShellCommandline( |
||
| 20 | 'docker-machine inspect '. |
||
| 21 | '--format=\'{{.Driver.IPAddress}}\' "${MACHINE_NAME}"' |
||
| 22 | ); |
||
| 23 | |||
| 24 | $processRunner->mustRun($process); |
||
| 25 | |||
| 26 | $str = trim($process->getOutput()); |
||
| 27 | |||
| 28 | return self::fromIP(new IP($str)); |
||
| 29 | } |
||
| 30 | |||
| 31 | public static function fromIP(IP $ip): self |
||
| 32 | { |
||
| 33 | $self = new self(); |
||
| 34 | $self->ip = $ip; |
||
| 35 | |||
| 36 | return $self; |
||
| 37 | } |
||
| 38 | |||
| 39 | public function toIP(): IP |
||
| 42 | } |
||
| 43 | |||
| 44 | /** |
||
| 45 | * @return string |
||
| 46 | */ |
||
| 47 | public function toString(): string |
||
| 50 | } |
||
| 51 | |||
| 52 | /** |
||
| 53 | * @return string |
||
| 54 | */ |
||
| 55 | public function __toString(): string |
||
| 60 |