Completed
Push — master ( e41e91...2b4213 )
by Aleh
01:47 queued 01:39
created

InterfaceData::addMethod()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 3
rs 10
cc 1
eloc 2
nc 1
nop 1
1
<?php
2
3
namespace Padawan\Domain\Project\Node;
4
5
use Padawan\Domain\Project\FQCN;
6
use Padawan\Domain\Project\Collection\MethodsCollection;
7
8
class InterfaceData
9
{
10
    public $fqcn;
11
    public $interfaces      = [];
12
    public $constants       = [];
13
    public $uses            = [];
14
    public $methods;
15
    public $file            = "";
16
    public $startLine       = 0;
17
    public $doc             = "";
18
    public function __construct(FQCN $fqcn, $file) {
19
        $this->fqcn = $fqcn;
20
        $this->file = $file;
21
        $this->methods = new MethodsCollection($this);
22
    }
23
    /** @return FQCN */
24
    public function getFQCN()
25
    {
26
        return $this->fqcn;
27
    }
28
    public function getName()
29
    {
30
        return $this->getFQCN()->getClassName();
31
    }
32
    public function addMethod(MethodData $method) {
33
        $this->methods->add($method);
34
    }
35
    public function getMethod($methodName)
36
    {
37
        return $this->methods->get($methodName);
38
    }
39
    public function hasMethod($methodName)
40
    {
41
        return $this->methods->get($methodName) !== null;
42
    }
43
    public function getInterfaces() {
44
        return $this->interfaces;
45
    }
46
    public function addInterface($interface) {
47
        $fqcn = $interface;
48
        if ($interface instanceof InterfaceData) {
49
            $fqcn = $interface->fqcn;
50
        }
51
        $this->interfaces[$fqcn->toString()] = $interface;
52
    }
53
}
54