Passed
Push — master ( 28894b...85e017 )
by Mariano
05:13
created

JsonPathConditionCollection   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 27
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 8
dl 0
loc 27
rs 10
c 1
b 0
f 0
wmc 5

4 Methods

Rating   Name   Duplication   Size   Complexity  
A iterator() 0 3 1
A key() 0 3 1
A __toString() 0 9 2
A setPathCondition() 0 3 1
1
<?php
2
3
namespace Mcustiel\Phiremock\Domain\Condition\Conditions;
4
5
use Mcustiel\Phiremock\Domain\AbstractArrayCollection;
6
use Mcustiel\Phiremock\Domain\Http\JsonPathName;
7
8
/** @method JsonPathCondition current() */
9
final class JsonPathConditionCollection extends AbstractArrayCollection
10
{
11
    public function __toString()
12
    {
13
        $string = '';
14
        /** @var JsonPathName $pathName */
15
        /** @var JsonPathCondition $condition */
16
        foreach ($this as $pathName => $condition) {
17
            $string .= $pathName->asString() . ' => ' . $condition->__toString();
18
        }
19
        return $string;
20
    }
21
22
    public function setPathCondition(JsonPathName $path, JsonPathCondition $condition)
23
    {
24
        parent::set($path->asString(), $condition);
25
    }
26
27
    /** @return JsonPathName */
28
    public function key()
29
    {
30
        return new JsonPathName(parent::key());
31
    }
32
33
    public function iterator()
34
    {
35
        return new JsonPathConditionIterator($this->array);
36
    }
37
}
38