Transforms::findByInputFieldName()   A
last analyzed

Complexity

Conditions 3
Paths 3

Size

Total Lines 10
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 6
CRAP Score 3

Importance

Changes 0
Metric Value
dl 0
loc 10
ccs 6
cts 6
cp 1
rs 9.4285
c 0
b 0
f 0
cc 3
eloc 5
nc 3
nop 1
crap 3
1
<?php
2
3
namespace PhMap;
4
5
use \ArrayIterator;
6
7
/**
8
 * Class Transforms
9
 * @package PhMap
10
 */
11
class Transforms extends ArrayIterator {
12
13
    /**
14
     * @param Transform $transform
15
     * @return $this
16
     */
17 3
    public function add(Transform $transform) {
18 3
        $this->append($transform);
19
20 3
        return $this;
21
    }
22
23
    /**
24
     * @param string $field
25
     * @return Transform|null
26
     */
27 3
    public function findByInputFieldName($field) {
28
        /** @var Transform $transform */
29 3
        foreach ($this as $transform) {
30 3
            if ($transform->getInputFieldName() === $field) {
31 3
                return $transform;
32
            }
33 3
        }
34
35 3
        return null;
36
    }
37
38
}