ConstraintResolver::resolveConstraints()   A
last analyzed

Complexity

Conditions 3
Paths 3

Size

Total Lines 16
Code Lines 9

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 16
rs 9.4285
c 0
b 0
f 0
cc 3
eloc 9
nc 3
nop 1
1
<?php
2
3
namespace ArgumentResolver\Resolution;
4
5
use ArgumentResolver\Argument\ArgumentDescriptions;
6
7
class ConstraintResolver
8
{
9
    /**
10
     * @param ArgumentDescriptions $descriptions
11
     *
12
     * @return ResolutionConstraintCollection
13
     */
14
    public function resolveConstraints(ArgumentDescriptions $descriptions)
15
    {
16
        $constraints = [];
17
        $types = [];
18
        foreach ($descriptions as $description) {
19
            if (in_array($description->getType(), $types)) {
20
                $constraints[] = new ResolutionConstraint(ResolutionConstraint::STRICT_MATCHING, [
21
                    'type' => $description->getType(),
22
                ]);
23
            }
24
25
            $types[] = $description->getType();
26
        }
27
28
        return new ResolutionConstraintCollection($constraints);
29
    }
30
}
31