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.

CoverFishMessageError   A
last analyzed

Complexity

Total Complexity 18

Size/Duplication

Total Lines 120
Duplicated Lines 40 %

Coupling/Cohesion

Components 0
Dependencies 3

Importance

Changes 1
Bugs 1 Features 0
Metric Value
wmc 18
lcom 0
cbo 3
dl 48
loc 120
rs 10
c 1
b 1
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
C getErrorStreamTemplate() 48 71 18

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
3
namespace DF\PHPCoverFish\Common;
4
5
use DF\PHPCoverFish\Common\CoverFishColor as Color;
6
7
/**
8
 * Class CoverFishMessageError, code coverage error definition
9
 *
10
 * @package   DF\PHPCoverFish
11
 * @author    Patrick Paechnatz <[email protected]>
12
 * @copyright 2015 Patrick Paechnatz <[email protected]>
13
 * @license   http://www.opensource.org/licenses/MIT
14
 * @link      http://github.com/dunkelfrosch/phpcoverfish/tree
15
 * @since     class available since Release 0.9.0
16
 * @version   0.9.9
17
 */
18
class CoverFishMessageError extends CoverFishMessage
19
{
20
    // reflection problem, cover class is not available during reflection using annotation defined namespace
21
    const PHPUNIT_REFLECTION_CLASS_NOT_FOUND = 1000;
22
    // reflection problem, cover class method is not available / not found during reflection using annotation defined namespace
23
    const PHPUNIT_REFLECTION_METHOD_NOT_FOUND = 2000;
24
    // reflection problem, class exists but no public methods available
25
    const PHPUNIT_REFLECTION_NO_PUBLIC_METHODS_FOUND = 2001;
26
    // reflection problem, class exists but no protected methods available
27
    const PHPUNIT_REFLECTION_NO_PROTECTED_METHODS_FOUND = 2002;
28
    // reflection problem, class exists but no protected methods available
29
    const PHPUNIT_REFLECTION_NO_PRIVATE_METHODS_FOUND = 2003;
30
    // reflection problem, class exists but no not public methods available
31
    const PHPUNIT_REFLECTION_NO_NOT_PUBLIC_METHODS_FOUND = 2004;
32
    // reflection problem, class exists but no not protected methods available
33
    const PHPUNIT_REFLECTION_NO_NOT_PROTECTED_METHODS_FOUND = 2005;
34
    // reflection problem, class exists but no not private methods available
35
    const PHPUNIT_REFLECTION_NO_NOT_PRIVATE_METHODS_FOUND = 2006;
36
    // class does not provide any of defined methods in corresponding visibility
37
    const PHPUNIT_REFLECTION_CLASS_NOT_DEFINED = 4000;
38
    // annotation problem, cover class not found or class part in 'class::method' not available
39
    const PHPUNIT_VALIDATOR_PROBLEM = 9000;
40
    // annotation problem, defaultCoverClass not found during global method validation
41
    const PHPUNIT_VALIDATOR_MISSING_DEFAULT_COVER_CLASS_PROBLEM = 9001;
42
43
    /**
44
     * @var array
45
     */
46
    public $messageTokens = array(
47
        self::PHPUNIT_REFLECTION_CLASS_NOT_FOUND => 'Class not found!', // annotation defined coverClass is not available during reflection, may be the class is not available system wide!
48
        self::PHPUNIT_REFLECTION_METHOD_NOT_FOUND => 'Method not found!', // annotation defined method is not available during reflection of corresponding coverClass!
49
        self::PHPUNIT_REFLECTION_NO_PUBLIC_METHODS_FOUND => 'no public methods in class!', // method-access/-visibility problem!
50
        self::PHPUNIT_REFLECTION_NO_PROTECTED_METHODS_FOUND => 'no protected methods in class!', // method-access/-visibility problem!
51
        self::PHPUNIT_REFLECTION_NO_PRIVATE_METHODS_FOUND => 'no private methods in class!', // method-access/-visibility problem!
52
        self::PHPUNIT_REFLECTION_NO_NOT_PUBLIC_METHODS_FOUND => 'no not public methods in class!', // method-access/-visibility problem!
53
        self::PHPUNIT_REFLECTION_NO_NOT_PROTECTED_METHODS_FOUND => 'no not protected methods in class!', // method-access/-visibility problem!
54
        self::PHPUNIT_REFLECTION_NO_NOT_PRIVATE_METHODS_FOUND => 'no not private methods in class!', // method-access/-visibility problem!
55
        self::PHPUNIT_REFLECTION_CLASS_NOT_DEFINED => 'Class not defined!', // class not defined, not found in use statement
56
        self::PHPUNIT_VALIDATOR_PROBLEM => 'cover Annotation problem!', // cover annotation spelling/validation error
57
        self::PHPUNIT_VALIDATOR_MISSING_DEFAULT_COVER_CLASS_PROBLEM => 'defaultCoverClass Annotation missing!', // defaultCoverClass annotation spelling/validation error
58
    );
59
60
    /**
61
     * @param CoverFishMapping $coverMapping
62
     * @param bool|false       $noAnsiColors
63
     *
64
     * @return null|string
65
     */
66
    public function getErrorStreamTemplate(CoverFishMapping $coverMapping, $noAnsiColors = false)
67
    {
68
        $coverLine = null;
69
        switch ($this->getMessageCode()) {
70 View Code Duplication
            case self::PHPUNIT_REFLECTION_CLASS_NOT_FOUND:
71
                $coverLine = sprintf('@covers %s::%s', $coverMapping->getClassFQN(), $coverMapping->getMethod());
72
                if (!$noAnsiColors) {
73
                    $coverLine  = Color::tplNormalColor('@covers ');
74
                    $coverLine .= Color::tplMarkFailure($coverMapping->getClassFQN());
75
                    $coverLine .= Color::tplYellowColor('::' . $coverMapping->getMethod());
76
                }
77
78
                if (null === $coverMapping->getMethod()) {
79
                    $coverLine = str_replace('::', null, $coverLine);
80
                }
81
82
                break;
83
84 View Code Duplication
            case self::PHPUNIT_REFLECTION_METHOD_NOT_FOUND:
85
                $coverLine = sprintf('@covers %s::%s', $coverMapping->getClassFQN(), $coverMapping->getMethod());
86
                if (!$noAnsiColors) {
87
                    $coverLine  = Color::tplNormalColor('@covers ');
88
                    $coverLine .= Color::tplYellowColor($coverMapping->getClassFQN() . '::');
89
                    $coverLine .= Color::tplMarkFailure($coverMapping->getMethod());
90
                }
91
92
                break;
93
94 View Code Duplication
            case self::PHPUNIT_REFLECTION_CLASS_NOT_DEFINED:
95
                $coverLine = sprintf('@covers %s', $coverMapping->getClassFQN());
96
                if (!$noAnsiColors) {
97
                    $coverLine  = Color::tplNormalColor('@covers ');
98
                    $coverLine .= Color::tplMarkFailure($coverMapping->getClassFQN());
99
                }
100
101
                break;
102
103
            case self::PHPUNIT_REFLECTION_NO_PUBLIC_METHODS_FOUND:
104
            case self::PHPUNIT_REFLECTION_NO_PROTECTED_METHODS_FOUND:
105
            case self::PHPUNIT_REFLECTION_NO_PRIVATE_METHODS_FOUND:
106
            case self::PHPUNIT_REFLECTION_NO_NOT_PUBLIC_METHODS_FOUND:
107
            case self::PHPUNIT_REFLECTION_NO_NOT_PROTECTED_METHODS_FOUND:
108 View Code Duplication
            case self::PHPUNIT_REFLECTION_NO_NOT_PRIVATE_METHODS_FOUND:
0 ignored issues
show
Coding Style introduced by
The case body in a switch statement must start on the line following the statement.

According to the PSR-2, the body of a case statement must start on the line immediately following the case statement.

switch ($expr) {
case "A":
    doSomething(); //right
    break;
case "B":

    doSomethingElse(); //wrong
    break;

}

To learn more about the PSR-2 coding standard, please refer to the PHP-Fig.

Loading history...
109
110
                $coverLine = sprintf('@covers %s::<%s>', $coverMapping->getClassFQN(), $coverMapping->getAccessor());
111
                if (!$noAnsiColors) {
112
                    $coverLine  = Color::tplNormalColor('@covers ');
113
                    $coverLine .= Color::tplYellowColor($coverMapping->getClassFQN() . '::<');
114
                    $coverLine .= Color::tplMarkFailure($coverMapping->getAccessor());
115
                    $coverLine .= Color::tplYellowColor('>');
116
                }
117
118
                break;
119
120 View Code Duplication
            case self::PHPUNIT_VALIDATOR_MISSING_DEFAULT_COVER_CLASS_PROBLEM:
121
                $coverLine = sprintf('@covers %s', $coverMapping->getClass());
122
                if (!$noAnsiColors) {
123
                    $coverLine  = Color::tplNormalColor('@covers ');
124
                    $coverLine .= Color::tplMarkFailure($coverMapping->getClass());
125
                }
126
                break;
127
128
            case self::PHPUNIT_VALIDATOR_PROBLEM:
129
                break;
130
131
            default:
132
                break;
133
        }
134
135
        return $coverLine;
136
    }
137
}