Completed
Push — master ( 7c66eb...e496eb )
by Edgar
06:39
created

Gradient::__construct()   A

Complexity

Conditions 4
Paths 6

Size

Total Lines 12
Code Lines 7

Duplication

Lines 5
Ratio 41.67 %

Code Coverage

Tests 7
CRAP Score 4.1755

Importance

Changes 2
Bugs 0 Features 0
Metric Value
c 2
b 0
f 0
dl 5
loc 12
ccs 7
cts 9
cp 0.7778
rs 9.2
cc 4
eloc 7
nc 6
nop 2
crap 4.1755
1
<?php
2
namespace nstdio\svg\gradient;
3
4
use nstdio\svg\container\SVG;
5
use nstdio\svg\ElementInterface;
6
use nstdio\svg\SVGElement;
7
use nstdio\svg\util\Identifier;
8
9
/**
10
 * Class Gradient
11
 *
12
 * @package nstdio\svg\gradient
13
 * @author  Edgar Asatryan <[email protected]>
14
 */
15
abstract class Gradient extends SVGElement
16
{
17
    const LINEAR = 'linear';
18
19
    const RADIAL = 'radial';
20
21 36
    public function __construct(ElementInterface $parent, $id = null)
22
    {
23 36 View Code Duplication
        if ($parent instanceof SVG) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
24 36
            $parent = $parent->getFirstChild();
25 36
        } elseif ($parent instanceof SVGElement) {
26
            $parent = $parent->getSVG()->getFirstChild();
27
        }
28
29 36
        parent::__construct($parent);
30
31 36
        $this->id = $id === null ? Identifier::random('__gradient', 4) : $id;
32 36
    }
33
34
    /**
35
     * @param Stop|Stop[] $stops
36
     */
37 36
    public function appendStop(Stop $stops)
0 ignored issues
show
Unused Code introduced by
The parameter $stops is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
38
    {
39 36
        $stops = func_get_args();
40 36
        foreach ($stops as $stop) {
41 36
            $this->append($stop);
42 36
        }
43
    }
44
}