Completed
Push — master ( c71ba2...adfa1d )
by Robbert
10:16
created

Writer   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 21
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Test Coverage

Coverage 75%

Importance

Changes 6
Bugs 3 Features 0
Metric Value
wmc 4
c 6
b 3
f 0
lcom 0
cbo 1
dl 0
loc 21
ccs 6
cts 8
cp 0.75
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __call() 0 4 1
A __construct() 0 9 3
1
<?php
2
/*
3
 * This file is part of the Ariadne Component Library.
4
 *
5
 * (c) Muze <[email protected]>
6
 *
7
 * For the full copyright and license information, please view the LICENSE
8
 * file that was distributed with this source code.
9
 */
10
namespace arc\html;
11
12
/**
13
 * This class allows you to create valid and nicely indented HTML strings
14
 * Any method not explicitly defined is interpreted as a new HTML element to create.
15
 */
16
class Writer {
17
18
    public $indent = "\t";
19
    public $newLine = "\r\n";
20
21 1
    public function __construct( $options = [] )
22
    {
23 1
        $optionList = ['indent','newLine'];
24 1
        foreach( $options as $option => $optionValue ) {
25
            if ( in_array( $option, $optionList ) ) {
26
                $this->{$option} = $optionValue;
27
            }
28
        }
29 1
    }
30
31 1
    public function __call( $name, $args )
32
    {
33 1
        return call_user_func_array( [ new \arc\html\NodeList( [], $this), $name], $args );
0 ignored issues
show
Documentation introduced by
$this is of type this<arc\html\Writer>, but the function expects a object<arc\xml\Writer>|null.

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...
34
    }
35
36
}
37
38