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.

ValidatorClassNameMethodAccess::validate()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 4
Code Lines 2

Duplication

Lines 4
Ratio 100 %

Importance

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