Completed
Push — master ( 34d315...a20938 )
by Garrett
09:58
created

HTMLStrObj   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 12
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 2
c 1
b 0
f 0
lcom 1
cbo 1
dl 0
loc 12
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A HTMLString::nl2br() 0 4 1
A HTMLString::nl2brX() 0 4 1
1
<?php
2
3
namespace StringObject\Decorator;
4
5
use StringObject\AnyString;
6
7
class HTMLString extends TextString
8
{
9
    public function nl2br()
10
    {
11
        return new self(\nl2br($this->raw, false));
0 ignored issues
show
Bug introduced by
The property raw does not exist. Did you maybe forget to declare it?

In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:

class MyClass { }

$x = new MyClass();
$x->foo = true;

Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion:

class MyClass {
    public $foo;
}

$x = new MyClass();
$x->foo = true;
Loading history...
Documentation introduced by
\nl2br($this->raw, false) is of type string, but the function expects a object<StringObject\AnyString>.

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...
12
    }
13
14
    public function nl2brX()
15
    {
16
        return new self(\nl2br($this->raw, true));
0 ignored issues
show
Documentation introduced by
\nl2br($this->raw, true) is of type string, but the function expects a object<StringObject\AnyString>.

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...
17
    }
18
}
19