ScalarCollectionNode   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 15
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

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

1 Method

Rating   Name   Duplication   Size   Complexity  
A getValue() 0 12 3
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Linio\Component\Input\Node;
6
7
use Linio\Component\Input\Exception\InvalidConstraintException;
8
9
class ScalarCollectionNode extends BaseNode
10
{
11
    public function getValue(string $field, $value)
12
    {
13
        $this->checkConstraints($field, $value);
14
15
        foreach ($value as $scalarValue) {
16
            if (!call_user_func('is_' . $this->type, $scalarValue)) {
17
                throw new InvalidConstraintException(sprintf('Value "%s" is not of type %s', $scalarValue, $this->type));
18
            }
19
        }
20
21
        return $value;
22
    }
23
}
24