1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace App\Support\Mechanics; |
4
|
|
|
|
5
|
|
|
use App\Support\Console\ConsoleWriter; |
6
|
|
|
use App\Support\Console\ServerBag; |
7
|
|
|
use App\Support\Contracts\Cli; |
8
|
|
|
|
9
|
|
|
class Untrained implements Mechanic |
10
|
|
|
{ |
11
|
|
|
/** @var Cli */ |
12
|
|
|
protected $cli; |
13
|
|
|
|
14
|
|
|
/** @var ConsoleWriter */ |
15
|
|
|
protected $consoleWriter; |
16
|
|
|
|
17
|
|
|
/** @var ServerBag */ |
18
|
|
|
protected $serverBag; |
19
|
|
|
|
20
|
|
|
/** @var string $hostAddress Address for Host */ |
21
|
|
|
protected $hostAddress = '127.0.0.1'; |
22
|
|
|
|
23
|
|
|
/** |
24
|
|
|
* Untrained constructor. |
25
|
|
|
* |
26
|
|
|
* @param Cli $cli |
27
|
|
|
* @param ConsoleWriter $consoleWriter |
28
|
|
|
* @param ServerBag $serverBag |
29
|
|
|
*/ |
30
|
121 |
|
public function __construct(Cli $cli, ConsoleWriter $consoleWriter, ServerBag $serverBag) |
31
|
|
|
{ |
32
|
121 |
|
$this->cli = $cli; |
33
|
121 |
|
$this->consoleWriter = $consoleWriter; |
34
|
121 |
|
$this->serverBag = $serverBag; |
35
|
121 |
|
} |
36
|
|
|
|
37
|
|
|
/** |
38
|
|
|
* Trust the given root certificate file in the Keychain. |
39
|
|
|
* |
40
|
|
|
* @param string $pem |
41
|
|
|
* |
42
|
|
|
* @return void |
43
|
|
|
*/ |
44
|
1 |
|
public function trustCA($pem) |
45
|
|
|
{ |
46
|
1 |
|
$this->iAmNotTrainedTo('trust a CA certificate'); |
47
|
1 |
|
} |
48
|
|
|
|
49
|
|
|
/** |
50
|
|
|
* Trust the given certificate file in the Mac Keychain. |
51
|
|
|
* |
52
|
|
|
* @param string $crt |
53
|
|
|
* |
54
|
|
|
* @return void |
55
|
|
|
*/ |
56
|
1 |
|
public function trustCertificate($crt) |
57
|
|
|
{ |
58
|
1 |
|
$this->iAmNotTrainedTo('trust a certificate'); |
59
|
1 |
|
} |
60
|
|
|
|
61
|
|
|
/** |
62
|
|
|
* Return the User's home directory path. |
63
|
|
|
* |
64
|
|
|
* @return string |
65
|
|
|
*/ |
66
|
1 |
|
public function getUserHomePath() |
67
|
|
|
{ |
68
|
1 |
|
$this->iAmNotTrainedTo('get the users home path'); |
69
|
1 |
|
} |
70
|
|
|
|
71
|
|
|
/** |
72
|
|
|
* Flush the host system DNS cache. |
73
|
|
|
* |
74
|
|
|
* @return void |
75
|
|
|
*/ |
76
|
1 |
|
public function flushDns() |
77
|
|
|
{ |
78
|
1 |
|
$this->iAmNotTrainedTo('flush the DNS'); |
79
|
1 |
|
} |
80
|
|
|
|
81
|
|
|
/** |
82
|
|
|
* Give a nice message about not being trained. |
83
|
|
|
* |
84
|
|
|
* @param $activity |
85
|
|
|
*/ |
86
|
6 |
|
protected function iAmNotTrainedTo($activity) |
87
|
|
|
{ |
88
|
6 |
|
$this->consoleWriter->info("I haven't been trained to {$activity} on this system."); |
89
|
6 |
|
$this->consoleWriter->info('You are welcome to train me and submit a PR.'); |
90
|
6 |
|
} |
91
|
|
|
|
92
|
|
|
/** |
93
|
|
|
* Setup networking for Porter. |
94
|
|
|
* |
95
|
|
|
* @return void |
96
|
|
|
*/ |
97
|
1 |
|
public function setupNetworking() |
98
|
|
|
{ |
99
|
1 |
|
$this->iAmNotTrainedTo('set up special networking for Porter'); |
100
|
1 |
|
} |
101
|
|
|
|
102
|
|
|
/** |
103
|
|
|
* Restore networking for Porter. |
104
|
|
|
* |
105
|
|
|
* @return void |
106
|
|
|
*/ |
107
|
1 |
|
public function restoreNetworking() |
108
|
|
|
{ |
109
|
1 |
|
$this->iAmNotTrainedTo('restore special networking for Porter'); |
110
|
1 |
|
} |
111
|
|
|
|
112
|
|
|
/** |
113
|
|
|
* Get Host IP for Porter. |
114
|
|
|
* |
115
|
|
|
* @return string |
116
|
|
|
*/ |
117
|
1 |
|
public function getHostAddress() |
118
|
|
|
{ |
119
|
1 |
|
return $this->hostAddress; |
120
|
|
|
} |
121
|
|
|
} |
122
|
|
|
|