GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.
Completed
Push — master ( 99078a...9605c1 )
by Oanh
02:49
created

Informer   A

Complexity

Total Complexity 14

Size/Duplication

Total Lines 97
Duplicated Lines 10.31 %

Coupling/Cohesion

Components 1
Dependencies 1

Test Coverage

Coverage 66.67%
Metric Value
wmc 14
lcom 1
cbo 1
dl 10
loc 97
ccs 30
cts 45
cp 0.6667
rs 10

7 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A startTask() 5 14 3
A endTask() 5 8 3
A onServer() 0 6 2
A endOnServer() 0 6 2
A taskError() 0 8 2
A taskException() 0 12 1

How to fix   Duplicated Code   

Duplicated Code

Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.

Common duplication problems, and corresponding solutions are:

1
<?php
2
/* (c) Anton Medvedev <[email protected]>
3
 *
4
 * For the full copyright and license information, please view the LICENSE
5
 * file that was distributed with this source code.
6
 */
7
8
namespace Deployer\Executor;
9
10
use Deployer\Console\Output\OutputWatcher;
11
use Symfony\Component\Console\Output\OutputInterface;
12
13
class Informer
14
{
15
    /**
16
     * @var \Deployer\Console\Output\OutputWatcher
17
     */
18
    private $output;
19
20
    /**
21
     * @param \Deployer\Console\Output\OutputWatcher $output
22
     */
23 18
    public function __construct(OutputWatcher $output)
24
    {
25 18
        $this->output = $output;
26 18
    }
27
28
    /**
29
     * @param string $taskName
30
     */
31 15
    public function startTask($taskName)
32
    {
33 15
        if ($this->output->getVerbosity() >= OutputInterface::VERBOSITY_NORMAL) {
34 14 View Code Duplication
            if ($this->output->getVerbosity() == OutputInterface::VERBOSITY_NORMAL) {
35 14
                $this->output->write("  ");
36 14
            } else {
37
                $this->output->write("➤ ");
38
            }
39
40 14
            $this->output->writeln("Executing task $taskName");
41
42 14
            $this->output->setWasWritten(false);
43 14
        }
44 15
    }
45
46
    /**
47
     * Print task was ok.
48
     */
49 16
    public function endTask()
50
    {
51 16 View Code Duplication
        if ($this->output->getVerbosity() == OutputInterface::VERBOSITY_NORMAL && !$this->output->getWasWritten()) {
52 12
            $this->output->write("\033[k\033[1A\r<info>✔</info>\n");
53 12
        } else {
54 5
            $this->output->writeln("<info>✔</info> Ok");
55
        }
56 16
    }
57
58
    /**
59
     * @param string $serverName
60
     */
61 15
    public function onServer($serverName)
62
    {
63 15
        if ($this->output->getVerbosity() >= OutputInterface::VERBOSITY_VERBOSE) {
64
            $this->output->writeln("⤷ on [$serverName]");
65
        }
66 15
    }
67
68
    /**
69
     * @param string $serverName
70
     */
71 14
    public function endOnServer($serverName)
72
    {
73 14
        if ($this->output->getVerbosity() >= OutputInterface::VERBOSITY_VERBOSE) {
74
            $this->output->writeln("<info>⤶</info> done on [$serverName]");
75
        }
76 14
    }
77
78
    /**
79
     * Print error.
80
     *
81
     * @param bool $nonFatal
82
     */
83 2
    public function taskError($nonFatal = true)
84
    {
85 2
        if ($nonFatal) {
86 1
            $this->output->writeln("<fg=yellow>✘</fg=yellow> Some errors occurred!");
87 1
        } else {
88 1
            $this->output->writeln("<fg=red>✘</fg=red> <options=underscore>Some errors occurred!</options=underscore>");
89
        }
90 2
    }
91
92
    /**
93
     * @param string $serverName
94
     * @param string $exceptionClass
95
     * @param string $message
96
     */
97
    public function taskException($serverName, $exceptionClass, $message)
98
    {
99
        $message = "    $message    ";
100
        $this->output->writeln([
101
            "",
102
            "<error>Exception [$exceptionClass] on [$serverName] server</error>",
103
            "<error>" . str_repeat(' ', strlen($message)) . "</error>",
104
            "<error>$message</error>",
105
            "<error>" . str_repeat(' ', strlen($message)) . "</error>",
106
            ""
107
        ]);
108
    }
109
}
110