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

JsonPathConditionCollection::key()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 1
nc 1
nop 0
dl 0
loc 3
rs 10
c 1
b 0
f 0
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