CodeParser   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 25
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

Changes 0
Metric Value
wmc 2
lcom 1
cbo 1
dl 0
loc 25
c 0
b 0
f 0
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A parser() 0 6 1
1
<?php
2
declare(strict_types=1);
3
4
/*
5
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
6
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
7
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
8
 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
9
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
10
 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
11
 * THE SOFTWARE.
12
 *
13
 * This software consists of voluntary contributions made by many individuals
14
 * and is licensed under the MIT license.
15
 *
16
 * Copyright (c) 2018 Yuuki Takezawa
17
 */
18
19
namespace Ytake\Lom;
20
21
use PhpParser\Parser;
22
use ReflectionClass;
23
24
/**
25
 * Class CodeParser.
26
 *
27
 * @author yuuki.takezawa<[email protected]>
28
 * @license http://opensource.org/licenses/MIT MIT
29
 */
30
class CodeParser
31
{
32
    /** @var Parser */
33
    protected $parser;
34
35
    /**
36
     * @param Parser $parser
37
     */
38
    public function __construct(Parser $parser)
39
    {
40
        $this->parser = $parser;
41
    }
42
43
    /**
44
     * @param ReflectionClass $reflectionClass
45
     *
46
     * @return null|\PhpParser\Node[]
47
     */
48
    public function parser(ReflectionClass $reflectionClass)
49
    {
50
        return $this->parser->parse(
51
            file_get_contents($reflectionClass->getFileName())
52
        );
53
    }
54
}
55