Completed
Push — master ( 716959...c2acd0 )
by Luis
04:37 queued 02:39
created

Definition   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 44
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
dl 0
loc 44
ccs 14
cts 14
cp 1
rs 10
c 0
b 0
f 0
wmc 5

5 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 5 1
A countMethodsByVisibility() 0 4 1
A extends() 0 3 1
A methods() 0 3 1
A name() 0 3 1
1
<?php
2
/**
3
 * PHP version 7.1
4
 *
5
 * This source file is subject to the license that is bundled with this package in the file LICENSE.
6
 */
7
8
namespace PhUml\Code;
9
10
use PhUml\Graphviz\HasNodeIdentifier;
11
use PhUml\Graphviz\ObjectHashIdentifier;
12
13
/**
14
 * Base class for interfaces and classes
15
 *
16
 * It does not support traits yet
17
 */
18
class Definition implements HasNodeIdentifier
19
{
20
    use ObjectHashIdentifier;
21
22
    /** @var string */
23
    protected $name;
24
25
    /** @var Method[] */
26
    protected $methods;
27
28
    /** @var Definition */
29
    protected $extends;
30
31
    /**
32
     * @param Method[] $methods
33
     */
34 195
    public function __construct(string $name, array $methods = [], Definition $extends = null)
35
    {
36 195
        $this->name = $name;
37 195
        $this->methods = $methods;
38 195
        $this->extends = $extends;
39 195
    }
40
41
    public function countMethodsByVisibility(Visibility $modifier): int
42
    {
43 12
        return \count(array_filter($this->methods, function (Method $method) use ($modifier) {
44 12
            return $method->hasVisibility($modifier);
45 12
        }));
46
    }
47
48 132
    public function name(): string
49
    {
50 132
        return $this->name;
51
    }
52
53
    /** @return Method[] */
54 42
    public function methods(): array
55
    {
56 42
        return $this->methods;
57
    }
58
59 30
    public function extends(): Definition
60
    {
61 30
        return $this->extends;
62
    }
63
}
64