InterfaceModel::getConstructAnnotation()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 9
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

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