OptionsTrait   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 35
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 5
c 1
b 0
f 0
dl 0
loc 35
rs 10
wmc 3

3 Methods

Rating   Name   Duplication   Size   Complexity  
A withOptions() 0 3 1
A options() 0 3 1
A __construct() 0 5 1
1
<?php
2
3
namespace ArgentCrusade\Forms\Traits;
4
5
use ArgentCrusade\Forms\FormField;
6
7
trait OptionsTrait
8
{
9
    /**
10
     * OptionsTrait constructor.
11
     *
12
     * @param string $label
13
     * @param array  $options
14
     */
15
    public function __construct(string $label, array $options = [])
16
    {
17
        parent::__construct($label);
18
19
        $this->withOptions($options);
20
    }
21
22
    /**
23
     * Set options list.
24
     *
25
     * @param array $options
26
     *
27
     * @return FormField
28
     */
29
    public function withOptions(array $options)
30
    {
31
        return $this->withParameter('options', $options);
0 ignored issues
show
Bug introduced by
It seems like withParameter() 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

31
        return $this->/** @scrutinizer ignore-call */ withParameter('options', $options);
Loading history...
32
    }
33
34
    /**
35
     * Get options list.
36
     *
37
     * @return array
38
     */
39
    public function options()
40
    {
41
        return $this->getParameter('options', []);
0 ignored issues
show
Bug introduced by
It seems like getParameter() 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

41
        return $this->/** @scrutinizer ignore-call */ getParameter('options', []);
Loading history...
42
    }
43
}
44