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.

ClassParser::canParseMethod()   B
last analyzed

Complexity

Conditions 5
Paths 5

Size

Total Lines 9
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 6
CRAP Score 5

Importance

Changes 0
Metric Value
dl 0
loc 9
rs 8.8571
c 0
b 0
f 0
ccs 6
cts 6
cp 1
cc 5
eloc 7
nc 5
nop 1
crap 5
1
<?php
2
/**
3
 * Copyright (C) 2013-2015
4
 * Piotr Olaszewski <[email protected]>
5
 *
6
 * Permission is hereby granted, free of charge, to any person obtaining a copy
7
 * of this software and associated documentation files (the "Software"), to deal
8
 * in the Software without restriction, including without limitation the rights
9
 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10
 * copies of the Software, and to permit persons to whom the Software is
11
 * furnished to do so, subject to the following conditions:
12
 *
13
 * The above copyright notice and this permission notice shall be included in
14
 * all copies or substantial portions of the Software.
15
 *
16
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19
 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21
 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22
 * SOFTWARE.
23
 */
24
namespace WSDL\Parser;
25
26
use Ouzo\Utilities\Strings;
27
use ReflectionClass;
28
use ReflectionMethod;
29
30
/**
31
 * ClassParser
32
 *
33
 * @author Piotr Olaszewski <[email protected]>
34
 */
35
class ClassParser
36
{
37
    /**
38
     * @var ReflectionClass
39
     */
40
    private $reflectedClass;
41
    /**
42
     * @var MethodParser[]
43
     */
44
    private $methodDocComments = array();
45
46 9
    public function __construct($className)
47
    {
48 9
        $this->reflectedClass = new ReflectionClass($className);
49 9
    }
50
51 9
    public function parse()
52
    {
53 9
        $this->allPublicMethodDocComment();
54 9
    }
55
56 9
    private function allPublicMethodDocComment()
57
    {
58 9
        $reflectionClassMethods = $this->reflectedClass->getMethods();
59 9
        foreach ($reflectionClassMethods as $reflectionMethod) {
60 9
            if ($this->canParseMethod($reflectionMethod)) {
61 9
                $methodName = $reflectionMethod->getName();
0 ignored issues
show
Bug introduced by
Consider using $reflectionMethod->name. There is an issue with getName() and APC-enabled PHP versions.
Loading history...
62 9
                $methodDocComment = $reflectionMethod->getDocComment();
63 9
                $this->methodDocComments[] = new MethodParser($methodName, $methodDocComment);
64 9
            }
65 9
        }
66 9
    }
67
68
    /**
69
     * @param ReflectionMethod $method
70
     * @return bool
71
     */
72 9
    private function canParseMethod(ReflectionMethod $method)
73
    {
74
        return
75 9
            Strings::contains($method->getDocComment(), '@WebMethod') &&
76 9
            $method->isPublic() &&
77 9
            !$method->isConstructor() &&
78 9
            !$method->isDestructor() &&
79 9
            !Strings::contains($method->getName(), '__');
0 ignored issues
show
Bug introduced by
Consider using $method->name. There is an issue with getName() and APC-enabled PHP versions.
Loading history...
80
    }
81
82
    /**
83
     * @return MethodParser[]
84
     */
85 9
    public function getMethods()
86
    {
87 9
        return $this->methodDocComments;
88
    }
89
}
90