Completed
Pull Request — master (#4)
by Auke
01:53
created

Writer::doctype()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 11
Code Lines 8

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 7
CRAP Score 2

Importance

Changes 2
Bugs 1 Features 0
Metric Value
c 2
b 1
f 0
dl 0
loc 11
ccs 7
cts 7
cp 1
rs 9.4285
cc 2
eloc 8
nc 2
nop 1
crap 2
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 1
namespace arc\html;
11
12 1
/**
13 1
 * 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 1
18 1
    public $indent = "\t";
19
    public $newLine = "\r\n";
20 1
21
    public function __construct( $options = [] ) 
22 1
    {
23
        $optionList = ['indent','newLine'];
24
        foreach( $options as $option => $optionValue ) {
25 1
            if ( in_array( $option, $optionList ) ) {
26
                $this->{$option} = $optionValue;
27 1
            }
28
        }
29
    }
30 1
31 1
    public function __call( $name, $args ) 
32
    {
33
        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