Completed
Push — master ( 9d450b...0b908e )
by Kevin
02:19
created

Html::getAllowedAttrbutes()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 11
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
c 1
b 0
f 1
dl 0
loc 11
rs 9.4285
cc 1
eloc 6
nc 1
nop 0
1
<?php
2
3
namespace Groundskeeper\Tokens\Elements;
4
5
use Groundskeeper\Configuration;
6
7
class Html extends OpenElement
8
{
9
    protected function getAllowedAttrbutes()
10
    {
11
        $htmlAllowedAttributes = array(
12
            '/^manifest$/i' => Element::ATTR_CS_STRING
13
        );
14
15
        return array_merge(
16
            $htmlAllowedAttributes,
17
            parent::getAllowedAttrbutes()
18
        );
19
    }
20
21 View Code Duplication
    public function validate(Configuration $configuration)
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
22
    {
23
        parent::validate($configuration);
24
25
        // If not valid, then we are done.
26
        if (!$this->isValid) {
0 ignored issues
show
Bug Best Practice introduced by
The expression $this->isValid of type null|boolean is loosely compared to false; this is ambiguous if the boolean can be false. You might want to explicitly use !== null instead.

If an expression can have both false, and null as possible values. It is generally a good practice to always use strict comparison to clearly distinguish between those two values.

$a = canBeFalseAndNull();

// Instead of
if ( ! $a) { }

// Better use one of the explicit versions:
if ($a !== null) { }
if ($a !== false) { }
if ($a !== null && $a !== false) { }
Loading history...
27
            return;
28
        }
29
30
        // If no cleaning, then we are done.
31
        if ($configuration->get('clean-strategy') == 'none') {
32
            return;
33
        }
34
35
        if ($this->getParent() !== null) {
36
            return $this->handleValidationError('Html element must not be nested.');
0 ignored issues
show
Bug introduced by
The call to handleValidationError() misses a required argument $message.

This check looks for function calls that miss required arguments.

Loading history...
Documentation introduced by
'Html element must not be nested.' is of type string, but the function expects a object<Groundskeeper\Configuration>.

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...
37
        }
38
    }
39
}
40