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
|
|
|
/** |
21
|
|
|
* Untrained constructor. |
22
|
|
|
* |
23
|
|
|
* @param Cli $cli |
24
|
|
|
* @param ConsoleWriter $consoleWriter |
25
|
|
|
* @param ServerBag $serverBag |
26
|
|
|
*/ |
27
|
14 |
|
public function __construct(Cli $cli, ConsoleWriter $consoleWriter, ServerBag $serverBag) |
28
|
|
|
{ |
29
|
14 |
|
$this->cli = $cli; |
30
|
14 |
|
$this->consoleWriter = $consoleWriter; |
31
|
14 |
|
$this->serverBag = $serverBag; |
32
|
14 |
|
} |
33
|
|
|
|
34
|
|
|
/** |
35
|
|
|
* Trust the given root certificate file in the Keychain. |
36
|
|
|
* |
37
|
|
|
* @param string $pem |
38
|
|
|
* |
39
|
|
|
* @return void |
40
|
|
|
*/ |
41
|
1 |
|
public function trustCA($pem) |
42
|
|
|
{ |
43
|
1 |
|
$this->iAmNotTrainedTo('trust a CA certificate'); |
44
|
1 |
|
} |
45
|
|
|
|
46
|
|
|
/** |
47
|
|
|
* Trust the given certificate file in the Mac Keychain. |
48
|
|
|
* |
49
|
|
|
* @param string $crt |
50
|
|
|
* |
51
|
|
|
* @return void |
52
|
|
|
*/ |
53
|
1 |
|
public function trustCertificate($crt) |
54
|
|
|
{ |
55
|
1 |
|
$this->iAmNotTrainedTo('trust a certificate'); |
56
|
1 |
|
} |
57
|
|
|
|
58
|
|
|
/** |
59
|
|
|
* Return the User's home directory path. |
60
|
|
|
* |
61
|
|
|
* @return string |
62
|
|
|
*/ |
63
|
1 |
|
public function getUserHomePath() |
64
|
|
|
{ |
65
|
1 |
|
$this->iAmNotTrainedTo('get the users home path'); |
66
|
1 |
|
} |
67
|
|
|
|
68
|
|
|
/** |
69
|
|
|
* Flush the host system DNS cache. |
70
|
|
|
* |
71
|
|
|
* @return void |
72
|
|
|
*/ |
73
|
1 |
|
public function flushDns() |
74
|
|
|
{ |
75
|
1 |
|
$this->iAmNotTrainedTo('flush the DNS'); |
76
|
1 |
|
} |
77
|
|
|
|
78
|
|
|
/** |
79
|
|
|
* Give a nice message about not being trained. |
80
|
|
|
* |
81
|
|
|
* @param $activity |
82
|
|
|
*/ |
83
|
4 |
|
protected function iAmNotTrainedTo($activity) |
84
|
|
|
{ |
85
|
4 |
|
$this->consoleWriter->info("I haven't been trained to {$activity} on this system."); |
86
|
4 |
|
$this->consoleWriter->info('You are welcome to train me and submit a PR.'); |
87
|
4 |
|
} |
88
|
|
|
} |
89
|
|
|
|