Completed
Push — statistics_refactoring ( b2d9c2 )
by Luis
13:39
created

Definition   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 27
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
dl 0
loc 27
rs 10
c 0
b 0
f 0
wmc 2

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 5 1
A countMethodsByVisibility() 0 4 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
    public $name;
24
25
    /** @var Method[] */
26
    public $functions;
27
28
    /** @var Definition */
29
    public $extends;
30
31
    /**
32
     * @param Method[] $methods
33
     */
34
    public function __construct(string $name, array $methods = [], Definition $extends = null)
35
    {
36
        $this->name = $name;
37
        $this->functions = $methods;
38
        $this->extends = $extends;
39
    }
40
41
    public function countMethodsByVisibility(Visibility $modifier): int
42
    {
43
        return \count(array_filter($this->functions, function (Method $method) use ($modifier) {
44
            return $method->modifier->equals($modifier);
45
        }));
46
    }
47
}
48