Failed Conditions
Pull Request — master (#45)
by Robin
03:05
created

Untrained   A

Complexity

Total Complexity 7

Size/Duplication

Total Lines 88
Duplicated Lines 0 %

Test Coverage

Coverage 22.73%

Importance

Changes 0
Metric Value
wmc 7
eloc 14
dl 0
loc 88
ccs 5
cts 22
cp 0.2273
rs 10
c 0
b 0
f 0

7 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 5 1
A getUserHomePath() 0 3 1
A flushDns() 0 3 1
A trustCertificate() 0 3 1
A isTesting() 0 3 1
A trustCA() 0 3 1
A iAmNotTrainedTo() 0 4 1
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 10
    public function __construct(Cli $cli, ConsoleWriter $consoleWriter, ServerBag $serverBag)
28
    {
29 10
        $this->cli = $cli;
30 10
        $this->consoleWriter = $consoleWriter;
31 10
        $this->serverBag = $serverBag;
32 10
    }
33
34
    /**
35
     * Trust the given root certificate file in the Keychain.
36
     *
37
     * @param string $pem
38
     *
39
     * @return void
40
     */
41
    public function trustCA($pem)
42
    {
43
        $this->iAmNotTrainedTo('trust a CA certificate');
44
    }
45
46
    /**
47
     * Trust the given certificate file in the Mac Keychain.
48
     *
49
     * @param string $crt
50
     *
51
     * @return void
52
     */
53
    public function trustCertificate($crt)
54
    {
55
        $this->iAmNotTrainedTo('trust a certificate');
56
    }
57
58
    /**
59
     * Return the User's home directory path.
60
     *
61
     * @return string
62
     */
63
    public function getUserHomePath()
64
    {
65
        $this->iAmNotTrainedTo('get the users home path');
66
    }
67
68
    /**
69
     * Flush the host system DNS cache.
70
     *
71
     * @return void
72
     */
73
    public function flushDns()
74
    {
75
        $this->iAmNotTrainedTo('flush the DNS');
76
    }
77
78
    /**
79
     * Check if we're running in test mode.
80
     *
81
     * @return bool
82
     */
83
    public function isTesting()
84
    {
85
        return running_tests();
86
    }
87
88
    /**
89
     * Give a nice message about not being trained.
90
     *
91
     * @param $activity
92
     */
93
    protected function iAmNotTrainedTo($activity)
94
    {
95
        $this->consoleWriter->info("I haven't been trained to {$activity} on this system.");
96
        $this->consoleWriter->info('You are welcome to train me and submit a PR.');
97
    }
98
}
99