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

Gradient   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 30
Duplicated Lines 16.67 %

Coupling/Cohesion

Components 0
Dependencies 3

Test Coverage

Coverage 86.67%

Importance

Changes 4
Bugs 0 Features 0
Metric Value
wmc 6
c 4
b 0
f 0
lcom 0
cbo 3
dl 5
loc 30
ccs 13
cts 15
cp 0.8667
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 5 12 4
A appendStop() 0 7 2

How to fix   Duplicated Code   

Duplicated Code

Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.

Common duplication problems, and corresponding solutions are:

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
}