ConstraintResolver   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 24
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Importance

Changes 0
Metric Value
wmc 3
lcom 0
cbo 2
dl 0
loc 24
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A resolveConstraints() 0 16 3
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