Completed
Push — develop ( 10d533...fd1d54 )
by Paul
02:00
created

InterfaceModel::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 2
nc 1
nop 0
dl 0
loc 4
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace PhpUnitGen\Model;
4
5
use Doctrine\Common\Collections\ArrayCollection;
6
use PhpUnitGen\Annotation\AnnotationInterface\AnnotationInterface;
7
use PhpUnitGen\Annotation\ConstructAnnotation;
8
use PhpUnitGen\Model\ModelInterface\InterfaceModelInterface;
9
use PhpUnitGen\Model\PropertyTrait\ClassLikeTrait;
10
use PhpUnitGen\Model\PropertyTrait\DocumentationTrait;
11
use PhpUnitGen\Model\PropertyTrait\NameTrait;
12
use PhpUnitGen\Model\PropertyTrait\NodeTrait;
13
14
/**
15
 * Class InterfaceModel.
16
 *
17
 * @author     Paul Thébaud <[email protected]>.
18
 * @copyright  2017-2018 Paul Thébaud <[email protected]>.
19
 * @license    https://opensource.org/licenses/MIT The MIT license.
20
 * @link       https://github.com/paul-thebaud/phpunit-generator
21
 * @since      Class available since Release 2.0.0.
22
 */
23
class InterfaceModel implements InterfaceModelInterface
24
{
25
    use NameTrait;
26
    use NodeTrait;
27
    use ClassLikeTrait;
28
    use DocumentationTrait;
29
30
    /**
31
     * InterfaceModel constructor.
32
     */
33
    public function __construct()
34
    {
35
        $this->functions   = new ArrayCollection();
36
        $this->annotations = new ArrayCollection();
37
    }
38
39
    /**
40
     * @return ConstructAnnotation|null The construct annotation, null if none.
41
     */
42
    public function getConstructAnnotation(): ?ConstructAnnotation
43
    {
44
        $annotations = $this->annotations->filter(function (AnnotationInterface $annotation) {
45
            return $annotation->getType() === AnnotationInterface::TYPE_CONSTRUCT;
46
        });
47
        if ($annotations->isEmpty()) {
48
            return null;
49
        }
50
        return $annotations->first();
51
    }
52
}
53