GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.
Passed
Push — master ( a1835d...10e84a )
by
unknown
02:48
created

Checkbox::__construct()   B

Complexity

Conditions 6
Paths 4

Size

Total Lines 39
Code Lines 24

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 6
eloc 24
nc 4
nop 2
dl 0
loc 39
rs 8.9137
c 0
b 0
f 0
1
<?php
2
/**
3
 * This file is part of the O2System Framework package.
4
 *
5
 * For the full copyright and license information, please view the LICENSE
6
 * file that was distributed with this source code.
7
 *
8
 * @author         Steeve Andrian Salim
9
 * @copyright      Copyright (c) Steeve Andrian Salim
10
 */
11
12
// ------------------------------------------------------------------------
13
14
namespace O2System\Framework\Libraries\Ui\Components\Form\Elements\Custom;
15
16
// ------------------------------------------------------------------------
17
18
use O2System\Framework\Libraries\Ui\Element;
19
20
/**
21
 * Class Checkbox
22
 *
23
 * @package O2System\Framework\Libraries\Ui\Components\Form
24
 */
25
class Checkbox extends Element
26
{
27
    /**
28
     * Checkbox::$input
29
     *
30
     * @var Input
0 ignored issues
show
Bug introduced by
The type O2System\Framework\Libra...m\Elements\Custom\Input was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
31
     */
32
    public $input;
33
34
    // ------------------------------------------------------------------------
35
36
    /**
37
     * Checkbox::__construct
38
     *
39
     * @param string|null   $label
40
     * @param array         $attributes
41
     */
42
    public function __construct($label = null, array $attributes = [])
43
    {
44
        parent::__construct('label');
45
46
        $this->attributes->addAttributeClass(['custom-control', 'custom-checkbox']);
47
48
        $attributes[ 'type' ] = 'checkbox';
49
50
        $checkbox = new Input();
51
        $checkbox->attributes->removeAttributeClass('form-control');
52
        $checkbox->attributes->addAttributeClass('custom-control-input');
53
54
        if (count($attributes)) {
55
            foreach ($attributes as $name => $value) {
56
                $checkbox->attributes->addAttribute($name, $value);
57
58
                if ($name === 'name') {
59
                    $this->entity->setEntityName('input-' . $value);
60
                    $label->entity->setEntityName('label-' . $value);
0 ignored issues
show
Bug introduced by
The property entity does not exist on string.
Loading history...
61
                    $label->attributes->addAttribute('for', $value);
0 ignored issues
show
Bug introduced by
The property attributes does not exist on string.
Loading history...
62
63
                    if ( ! array_key_exists('id', $attributes)) {
64
                        $checkbox->attributes->setAttributeId('input-' . $value);
65
                    }
66
                }
67
            }
68
        }
69
70
        $this->input = $this->childNodes->push($checkbox);
0 ignored issues
show
Bug introduced by
Are you sure the assignment to $this->input is correct as $this->childNodes->push($checkbox) targeting O2System\Html\Element\Nodes::push() seems to always return null.

This check looks for function or method calls that always return null and whose return value is assigned to a variable.

class A
{
    function getObject()
    {
        return null;
    }

}

$a = new A();
$object = $a->getObject();

The method getObject() can return nothing but null, so it makes no sense to assign that value to a variable.

The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes.

Loading history...
71
72
        $indicator = new Element('span');
73
        $indicator->attributes->addAttributeClass('custom-control-indicator');
74
        $this->childNodes->push($indicator);
75
76
        if (isset($label)) {
77
            $description = new Element('span');
78
            $description->attributes->addAttributeClass('custom-control-description');
79
            $description->textContent->push(trim($label));
80
            $this->childNodes->push($indicator);
81
        }
82
    }
83
}