Completed
Push — master ( 9e4d7b...c3f58e )
by Gabriel
03:57 queued 11s
created

HasElementsTrait::setElements()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 1
dl 0
loc 3
ccs 0
cts 2
cp 0
rs 10
c 1
b 0
f 0
cc 1
nc 1
nop 1
crap 2
1
<?php
2
3
namespace Nip\Form\Renderer\Traits;
4
5
/**
6
 * Trait HasElementsTrait
7
 * @package Nip\Form\Renderer\Traits
8
 */
9
trait HasElementsTrait
10
{
11
    protected $elements = null;
12
13
    /**
14
     * @return array
15
     */
16 1
    public function getElements()
17
    {
18 1
        if ($this->elements === null) {
19 1
            $this->elements = $this->getForm()->getElements();
0 ignored issues
show
Bug introduced by
It seems like getForm() must be provided by classes using this trait. How about adding it as abstract method to this trait? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

19
            $this->elements = $this->/** @scrutinizer ignore-call */ getForm()->getElements();
Loading history...
20
        }
21
22 1
        return $this->elements;
23
    }
24
25
    /**
26
     * @param $elements
27
     */
28
    public function setElements($elements)
29
    {
30
        $this->elements = $elements;
31
    }
32
}
33