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

Form::addElement()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

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