Completed
Push — master ( 4dd860...67b321 )
by Nikola
03:47
created

FileMetadata::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 8
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 7
CRAP Score 1

Importance

Changes 0
Metric Value
c 0
b 0
f 0
dl 0
loc 8
ccs 7
cts 7
cp 1
rs 9.4285
cc 1
eloc 6
nc 1
nop 5
crap 1
1
<?php
2
/*
3
 * This file is part of the Abstract builder package, an RunOpenCode project.
4
 *
5
 * (c) 2017 RunOpenCode
6
 *
7
 * For the full copyright and license information, please view the LICENSE
8
 * file that was distributed with this source code.
9
 */
10
namespace RunOpenCode\AbstractBuilder\Ast\Metadata;
11
12
/**
13
 * Class FileMetadata
14
 *
15
 * @package RunOpenCode\AbstractBuilder\Ast\Metadata
16
 */
17
class FileMetadata
18
{
19
    /**
20
     * @var string
21
     */
22
    private $filename;
23
24
    /**
25
     * @var array
26
     */
27
    private $uses;
28
29
    /**
30
     * @var ClassMetadata[]
31
     */
32
    private $classes;
33
34
    /**
35
     * @var TraitMetadata[]
36
     */
37
    private $traits;
38
39
    /**
40
     * @var array
41
     */
42
    private $ast;
43
44
    /**
45
     * FileMetadata constructor.
46
     *
47
     * @param string $filename
48
     * @param array $classes
49
     * @param array $traits
50
     * @param array $ast
51
     */
52 2
    public function __construct($filename, array $uses = [], array $classes = [], array $traits = [], array $ast = [])
53
    {
54 2
        $this->filename = $filename;
55 2
        $this->uses = $uses;
56 2
        $this->classes = $classes;
57 2
        $this->traits = $traits;
58 2
        $this->ast = $ast;
59 2
    }
60
61
    /**
62
     * @return string
63
     */
64 1
    public function getFilename()
65
    {
66 1
        return $this->filename;
67
    }
68
69
    /**
70
     * @return array
71
     */
72
    public function getUses()
73
    {
74
        return $this->uses;
75
    }
76
77
    /**
78
     * Check if class is defined within file.
79
     *
80
     * @param string $name
81
     * @return bool
82
     */
83
    public function hasClass($name)
84
    {
85
        return isset($this->classes[trim($name, '\\')]);
86
    }
87
88
    /**
89
     * Get class definition from file.
90
     *
91
     * @param string $name
92
     * @return ClassMetadata
93
     */
94 2
    public function getClass($name)
95
    {
96 2
        return $this->classes[trim($name, '\\')];
97
    }
98
99
    /**
100
     * @return ClassMetadata[]
101
     */
102
    public function getClasses()
103
    {
104
        return $this->classes;
105
    }
106
107
    /**
108
     * @return TraitMetadata[]
109
     */
110
    public function getTraits()
111
    {
112
        return $this->traits;
113
    }
114
115
    /**
116
     * @return array
117
     */
118 2
    public function getAst()
119
    {
120 2
        return $this->ast;
121
    }
122
}
123