Completed
Push — master ( 591275...24655e )
by Derek Stephen
01:52
created

FieldCollection::findByName()   A

Complexity

Conditions 3
Paths 3

Size

Total Lines 13
Code Lines 8

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 8
CRAP Score 3.0123

Importance

Changes 0
Metric Value
dl 0
loc 13
ccs 8
cts 9
cp 0.8889
rs 9.4285
c 0
b 0
f 0
cc 3
eloc 8
nc 3
nop 1
crap 3.0123
1
<?php
2
/**
3
 * User: delboy1978uk
4
 * Date: 19/11/2016
5
 * Time: 12:18
6
 */
7
8
namespace Del\Form\Collection;
9
10
use Del\Common\Collection\AbstractCollection;
11
use Del\Common\Collection\CollectionInterface;
12
use Del\Form\Field\FieldInterface;
13
14
class FieldCollection extends AbstractCollection implements CollectionInterface
15
{
16
    /**
17
     * @param $name
18
     */
19 3
    public function findByName($name)
20
    {
21 3
        $this->rewind();
22 3
        while ($this->valid()) {
23
            /** @var FieldInterface $field */
24 2
            $field = $this->current();
25 2
            if($field->getName() == $name) {
26 2
                return $field;
27
            }
28
        }
29 1
        $this->rewind();
30 1
        return null;
31
    }
32
}