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.

ValidatorClassNameMethodName::getMapping()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 18
Code Lines 13

Duplication

Lines 18
Ratio 100 %

Importance

Changes 0
Metric Value
dl 18
loc 18
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 13
nc 1
nop 1
1
<?php
2
3
namespace DF\PHPCoverFish\Validator;
4
5
use DF\PHPCoverFish\Common\CoverFishMapping;
6
use DF\PHPCoverFish\Common\CoverFishPHPUnitFile;
7
use DF\PHPCoverFish\Validator\Base\BaseCoverFishValidator;
8
9
/**
10
 * Class ValidatorClassNameMethodName, validate that the annotated test method covers the specified method (Class::Method)
11
 *
12
 * @package   DF\PHPCoverFish
13
 * @author    Patrick Paechnatz <[email protected]>
14
 * @copyright 2015 Patrick Paechnatz <[email protected]>
15
 * @license   http://www.opensource.org/licenses/MIT
16
 * @link      http://github.com/dunkelfrosch/phpcoverfish/tree
17
 * @since     class available since Release 0.9.0
18
 * @version   0.9.4
19
 */
20 View Code Duplication
class ValidatorClassNameMethodName extends BaseCoverFishValidator
21
{
22
    /**
23
     * @return array
24
     */
25
    private function execute()
26
    {
27
        preg_match_all('/^(?P<class>(^(([\\\\])|([A-Z]))([A-Za-z0-9_\\\\]+)))(?P<sep>::{1})((?P<method>[\w]+))$/', $this->coversToken, $this->result, PREG_SET_ORDER);
28
29
        return $this->result;
30
    }
31
32
    /**
33
     * @return bool
34
     */
35
    public function validate()
36
    {
37
        return (count($this->execute()) > 0) && $this->validateResultKeys();
38
    }
39
40
    /**
41
     * @return bool
42
     */
43
    public function validateResultKeys()
44
    {
45
        return array_key_exists('class', $this->getResult())
46
            && array_key_exists('sep', $this->getResult())
47
            && array_key_exists('method', $this->getResult()
48
        );
49
    }
50
51
    /**
52
     * @param CoverFishPHPUnitFile $phpUnitFile
53
     *
54
     * @return CoverFishMapping
55
     */
56
    public function getMapping(CoverFishPHPUnitFile $phpUnitFile)
57
    {
58
        $method = $this->getResult()['method'];
59
        $class = $this->getResult()['class'];
60
        $classFQN = $this->coverFishHelper->getClassFromUse($class, $phpUnitFile->getUsedClasses());
61
62
        $mappingOptions = array(
63
            'coverToken' => $this->coversToken,
64
            'coverMethod' => $method,
65
            'coverAccessor' => null,
66
            'coverClass' => $class,
67
            'coverClassFQN' => $classFQN,
68
            'validatorMatch' => $this->getValidationTag(),
69
            'validatorClass' => get_class($this)
70
        );
71
72
        return $this->setMapping($mappingOptions);
73
    }
74
75
    /**
76
     * @return string
77
     */
78
    public function getValidationInfo()
79
    {
80
        return 'Specifies that the annotated test method covers the specified method.';
81
    }
82
83
    /**
84
     * @return string
85
     */
86
    public function getValidationTag()
87
    {
88
        return 'ClassName::methodName';
89
    }
90
91
    /**
92
     * @return string
93
     */
94
    public function __toString()
95
    {
96
        return get_class($this);
97
    }
98
}