| Total Complexity | 8 |
| Total Lines | 48 |
| Duplicated Lines | 0 % |
| Coverage | 88.89% |
| Changes | 0 | ||
| 1 | <?php |
||
| 11 | class ConstraintsResolver |
||
| 12 | { |
||
| 13 | /** |
||
| 14 | * @var ReflectionProperty |
||
| 15 | */ |
||
| 16 | protected $reflection; |
||
| 17 | |||
| 18 | /** |
||
| 19 | * @var array |
||
| 20 | */ |
||
| 21 | protected $annotations; |
||
| 22 | |||
| 23 | /** |
||
| 24 | * TypeResolver constructor. |
||
| 25 | * @param ReflectionProperty $reflection |
||
| 26 | * @param array $annotations |
||
| 27 | */ |
||
| 28 | 36 | final public function __construct(ReflectionProperty $reflection, array $annotations) |
|
| 29 | { |
||
| 30 | 36 | $this->reflection = $reflection; |
|
| 31 | 36 | $this->annotations = $annotations; |
|
| 32 | 36 | } |
|
| 33 | |||
| 34 | 36 | public function resolve(): array |
|
| 35 | { |
||
| 36 | 36 | $constraints = []; |
|
| 37 | 36 | foreach ($this->annotations as $annotation) { |
|
| 38 | 7 | if ($annotation instanceof Inherit) { |
|
| 39 | 1 | $constraints = array_merge($constraints, $this->getParentConstraints()); |
|
| 40 | 7 | } elseif ($annotation instanceof Constraint) { |
|
| 41 | 7 | $constraints[] = $annotation; |
|
| 42 | } |
||
| 43 | } |
||
| 44 | |||
| 45 | 36 | return $constraints; |
|
| 46 | } |
||
| 47 | |||
| 48 | 1 | protected function getParentConstraints() |
|
| 59 | } |
||
| 60 | } |
||
| 61 |