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