Completed
Push — master ( ebc724...0d59f6 )
by wen
02:37
created

Form   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 28
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

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

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A setElements() 0 6 1
A addElement() 0 6 1
1
<?php
2
3
namespace Sco\Admin\Form;
4
5
use Sco\Admin\Contracts\Form\Elements\ElementInterface;
6
use Sco\Admin\Contracts\Form\FormInterface;
7
8
class Form implements FormInterface
9
{
10
    protected $elements;
11
12
    public function __construct(array $elements = [])
13
    {
14
        $this->setElements($elements);
15
    }
16
17
    public function setElements(array $elements)
18
    {
19
        $this->elements = new ElementsCollection($elements);
20
21
        return $this;
22
    }
23
24
    /**
25
     * @param \Sco\Admin\Contracts\Form\Elements\ElementInterface $element
26
     *
27
     * @return $this
28
     */
29
    public function addElement(ElementInterface $element)
30
    {
31
        $this->elements->push($element);
32
33
        return $this;
34
    }
35
}
36