StyleTrait   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 11
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
dl 0
loc 11
c 0
b 0
f 0
wmc 2
lcom 1
cbo 1
ccs 6
cts 6
cp 1
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A setStyle() 0 8 2
1
<?php
2
namespace nstdio\svg\traits;
3
use nstdio\svg\util\KeyValueWriter;
4
5
/**
6
 * trait StyleTrait
7
 *
8
 * @package nstdio\svg\traits
9
 * @author  Edgar Asatryan <[email protected]>
10
 */
11
trait StyleTrait
12
{
13 2
    public function setStyle($style)
14
    {
15 2
        if (is_array($style)) {
16 1
            $this->style = KeyValueWriter::styleArrayToString($style);
0 ignored issues
show
Bug introduced by
The property style 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...
17 1
        } else {
18 1
            $this->style = $style;
19
        }
20
    }
21
}