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.

CoverFishMessageWarning   A
last analyzed

Complexity

Total Complexity 7

Size/Duplication

Total Lines 57
Duplicated Lines 45.61 %

Coupling/Cohesion

Components 0
Dependencies 3

Importance

Changes 1
Bugs 1 Features 0
Metric Value
wmc 7
lcom 0
cbo 3
dl 26
loc 57
rs 10
c 1
b 1
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
C getWarningStreamTemplate() 26 38 7

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 CoverFishMessageWarning, code coverage warning definition - used in feature version of coverFish
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.9
16
 * @version   1.0.0
17
 *
18
 * - no coverage found (implemented)
19
 * - double covers in methods
20
 * - double covers in class and methods
21
 * - obsolete multi-type coverage
22
 *
23
 */
24
class CoverFishMessageWarning extends CoverFishMessage
25
{
26
    // no coverage found
27
    const PHPUNIT_NO_COVERAGE_FOR_METHOD = 1000;
28
    const PHPUNIT_NO_DOCBLOCK_FOR_METHOD = 1001;
29
    
30
    /** @var array */
31
    public $messageTokens = array(
32
        self::PHPUNIT_NO_COVERAGE_FOR_METHOD => 'no coverage for this method!',
33
        self::PHPUNIT_NO_DOCBLOCK_FOR_METHOD => 'no phpdoc block for this method!',
34
    );
35
36
    /**
37
     * @param CoverFishMapping $coverMapping
38
     * @param bool|false       $noAnsiColors
39
     *
40
     * @return null|string
41
     */
42
    public function getWarningStreamTemplate(CoverFishMapping $coverMapping, $noAnsiColors = false)
43
    {
44
        $coverLine = null;
45
        switch ($this->getMessageCode()) {
46 View Code Duplication
            case self::PHPUNIT_NO_COVERAGE_FOR_METHOD:
47
                $coverLine = sprintf('no @covers annotation for %s::%s', $coverMapping->getClassFQN(), $coverMapping->getMethod());
48
                if (!$noAnsiColors) {
49
                    $coverLine  = Color::tplNormalColor('no @covers annotation for ');
50
                    $coverLine .= Color::tplYellowColor($coverMapping->getClassFQN());
51
                    $coverLine .= Color::tplYellowColor('::' . $coverMapping->getMethod());
52
                }
53
54
                if (null === $coverMapping->getMethod()) {
55
                    $coverLine = str_replace('::', null, $coverLine);
56
                }
57
58
                break;
59
60 View Code Duplication
            case self::PHPUNIT_NO_DOCBLOCK_FOR_METHOD:
61
                $coverLine = sprintf('no phpdoc block for %s::%s', $coverMapping->getClassFQN(), $coverMapping->getMethod());
62
                if (!$noAnsiColors) {
63
                    $coverLine  = Color::tplNormalColor('no phpdoc block for ');
64
                    $coverLine .= Color::tplYellowColor($coverMapping->getClassFQN());
65
                    $coverLine .= Color::tplYellowColor('::' . $coverMapping->getMethod());
66
                }
67
68
                if (null === $coverMapping->getMethod()) {
69
                    $coverLine = str_replace('::', null, $coverLine);
70
                }
71
72
                break;
73
74
            default:
75
                break;
76
        }
77
78
        return $coverLine;
79
    }
80
}