Completed
Push — master ( af7add...6e606c )
by Karsten
02:11
created

EntityConfig::getNumMarkedProperties()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 4
ccs 2
cts 2
cp 1
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 0
crap 1
1
<?php
2
/**
3
 * File was created 10.10.2015 18:11
4
 */
5
6
namespace PeekAndPoke\Component\Slumber\Core\LookUp;
7
8
use PeekAndPoke\Component\Creator\Creator;
9
use PeekAndPoke\Component\Slumber\Annotation\ClassMarker;
10
11
/**
12
 * @author Karsten J. Gerber <[email protected]>
13
 */
14
class EntityConfig
15
{
16
    /** @var string */
17
    protected $className;
18
    /** @var Creator */
19
    protected $creator;
20
    /** @var ClassMarker[] */
21
    protected $markersOnClass;
22
    /** @var PropertyMarkedForSlumber[] */
23
    protected $markedProperties;
24
25
    /**
26
     * @param string                     $className
27
     * @param Creator                    $creator
28
     * @param ClassMarker[]              $markersOnClass
29
     * @param PropertyMarkedForSlumber[] $markedProperties
30
     */
31 39
    public function __construct($className, Creator $creator, $markersOnClass, $markedProperties)
32
    {
33 39
        $this->className        = $className;
34 39
        $this->creator          = $creator;
35 39
        $this->markersOnClass   = $markersOnClass;
36 39
        $this->markedProperties = $markedProperties;
37 39
    }
38
39
    /**
40
     * @return string
41
     */
42
    public function getClassName()
43
    {
44
        return $this->className;
45
    }
46
47
    /**
48
     * @return Creator
49
     */
50 13
    public function getCreator()
51
    {
52 13
        return $this->creator;
53
    }
54
55
    /**
56
     * @return ClassMarker[]
57
     */
58
    public function getMarkersOnClass()
59
    {
60
        return $this->markersOnClass;
61
    }
62
63
    /**
64
     * @return PropertyMarkedForSlumber[]
65
     */
66 25
    public function getMarkedProperties()
67
    {
68 25
        return $this->markedProperties;
69
    }
70
71
    /**
72
     * @return int
73
     */
74 1
    public function getNumMarkedProperties()
75
    {
76 1
        return \count($this->markedProperties);
77
    }
78
79
    /**
80
     * @param string $name
81
     *
82
     * @return null|PropertyMarkedForSlumber
83
     */
84 9
    public function getMarkedPropertyByName($name)
85
    {
86 9
        foreach ($this->markedProperties as $property) {
87 9
            if ($property->name === $name) {
88 9
                return $property;
89
            }
90
        }
91
92 2
        return null;
93
    }
94
}
95