ObjectRadio   A
last analyzed

Complexity

Total Complexity 8

Size/Duplication

Total Lines 64
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Test Coverage

Coverage 68.42%

Importance

Changes 0
Metric Value
wmc 8
lcom 1
cbo 2
dl 0
loc 64
ccs 13
cts 19
cp 0.6842
rs 10
c 0
b 0
f 0

5 Methods

Rating   Name   Duplication   Size   Complexity  
A setValue() 0 4 1
A getValueOptions() 0 14 3
A setOptions() 0 6 1
A setOption() 0 6 1
A getProxy() 0 8 2
1
<?php
2
3
declare(strict_types=1);
4
5
namespace DoctrineModule\Form\Element;
6
7
use Laminas\Form\Element\Radio as RadioElement;
8
use Traversable;
9
10
class ObjectRadio extends RadioElement
11
{
12
    /** @var Proxy */
13
    protected $proxy;
14
15 3
    public function getProxy() : Proxy
16
    {
17 3
        if ($this->proxy === null) {
18
            $this->proxy = new Proxy();
19
        }
20
21 3
        return $this->proxy;
22
    }
23
24
    /**
25
     * @param array|Traversable $options
26
     *
27
     * {@inheritDoc}
28
     */
29
    public function setOptions($options) : self
30
    {
31
        $this->getProxy()->setOptions($options);
0 ignored issues
show
Documentation introduced by
$options is of type array|object<Traversable>, but the function expects a array<integer,*>.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
32
33
        return parent::setOptions($options);
34
    }
35
36
    /**
37
     * @param mixed $value
38
     *
39
     * {@inheritDoc}
40
     */
41 1
    public function setOption($key, $value) : self
42
    {
43 1
        $this->getProxy()->setOptions([$key => $value]);
44
45 1
        return parent::setOption($key, $value);
46
    }
47
48
    /**
49
     * {@inheritDoc}
50
     */
51
    public function setValue($value)
52
    {
53
        return parent::setValue($this->getProxy()->getValue($value));
54
    }
55
56
    /**
57
     * {@inheritDoc}
58
     */
59 2
    public function getValueOptions()
60
    {
61 2
        if (! empty($this->valueOptions)) {
62 1
            return $this->valueOptions;
63
        }
64
65 2
        $proxyValueOptions = $this->getProxy()->getValueOptions();
66
67 2
        if (! empty($proxyValueOptions)) {
68 1
            $this->setValueOptions($proxyValueOptions);
69
        }
70
71 2
        return $this->valueOptions;
72
    }
73
}
74