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

HasElementsTrait   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 22
Duplicated Lines 0 %

Test Coverage

Coverage 66.67%

Importance

Changes 2
Bugs 1 Features 0
Metric Value
wmc 3
eloc 6
dl 0
loc 22
ccs 4
cts 6
cp 0.6667
rs 10
c 2
b 1
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A getElements() 0 7 2
A setElements() 0 3 1
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