Input   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 28
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 3
lcom 0
cbo 2
dl 0
loc 28
ccs 8
cts 8
cp 1
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A render() 0 12 3
1
<?php
2
3
/**
4
 * This file is part of slick/form package
5
 *
6
 * For the full copyright and license information, please view the LICENSE
7
 * file that was distributed with this source code.
8
 */
9
10
namespace Slick\Form\Renderer;
11
12
/**
13
 * Input renderer
14
 *
15
 * @package Slick\Form\Renderer
16
 */
17
class Input extends Div implements RendererInterface
18
{
19
20
    /**
21
     * @var string The template file to use in the rendering
22
     */
23
    public $template = 'form-inputs/text.twig';
24
25
    /**
26
     * Render the HTML element in the provided context
27
     *
28
     * @param array $context
29
     *
30
     * @return string The HTML string output
31
     */
32 8
    public function render($context = [])
33
    {
34 8
        if ($element = $this->getElement()) {
35 8
            $class = $element->getAttribute('class', false);
0 ignored issues
show
Documentation introduced by
false is of type boolean, but the function expects a null|string.

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...
36
            $class .= $class
37 8
                ? ' form-control'
38 8
                : 'form-control';
39 8
            $this->getElement()->setAttribute('class', $class);
40 8
        }
41
42 8
        return parent::render($context);
43
    }
44
}