Str   A
last analyzed

Complexity

Total Complexity 6

Size/Duplication

Total Lines 34
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Importance

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

5 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A setValue() 0 4 1
A __toString() 0 7 2
A setParent() 0 4 1
A describe() 0 4 1
1
<?php
2
3
namespace hemio\html;
4
5
class Str implements Interface_\ContentModelText
6
{
7
8
    use Trait_\HooksToString;
9
    protected $strContent = '';
10
11
    public function __construct($content)
12
    {
13
        $this->strContent = $content;
14
    }
15
16
    public function setValue($content)
17
    {
18
        $this->strContent = $content;
19
    }
20
21
    public function __toString()
22
    {
23
        foreach ($this->hooksToString as $hook)
24
            $hook($this);
25
26
        return htmlspecialchars($this->strContent);
27
    }
28
29
    public function setParent(Abstract_\ElementContent $objParent)
30
    {
31
        $this->objParent = $objParent;
0 ignored issues
show
Bug introduced by
The property objParent 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...
32
    }
33
34
    public function describe()
35
    {
36
        return 'STRING';
37
    }
38
}
39