Completed
Push — issue/87 ( bbd942 )
by Alex
04:44
created

Category   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 35
Duplicated Lines 25.71 %

Coupling/Cohesion

Components 0
Dependencies 3

Test Coverage

Coverage 53.85%

Importance

Changes 0
Metric Value
wmc 2
lcom 0
cbo 3
dl 9
loc 35
ccs 7
cts 13
cp 0.5385
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A setProperty() 0 11 1
A createCategoryElement() 9 9 1

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
/*
3
 * This file is part of the feed-io package.
4
 *
5
 * (c) Alexandre Debril <[email protected]>
6
 *
7
 * For the full copyright and license information, please view the LICENSE
8
 * file that was distributed with this source code.
9
 */
10
11
namespace FeedIo\Rule\Atom;
12
13
use FeedIo\Feed\Node\CategoryInterface;
14
use FeedIo\Feed\NodeInterface;
15
16
class Category extends \FeedIo\Rule\Category
17
{
18
        
19
    /**
20
     * @param  NodeInterface $node
21
     * @param  \DOMElement   $element
22
     * @return mixed
23
     */
24 1
    public function setProperty(NodeInterface $node, \DOMElement $element)
25
    {
26 1
        $category = $node->newCategory();
27 1
        $category->setScheme($this->getAttributeValue($element, 'scheme'))
28 1
        ->setLabel($this->getAttributeValue($element, 'label'))
29 1
        ->setTerm($this->getAttributeValue($element, 'term'));
30
        
31 1
        $node->addCategory($category);        
32
33 1
        return $this;
34
    }
35
    
36
    /**
37
     * @param  \DomDocument   $document
38
     * @param  CategoryInterface $category
39
     * @return \DomElement
40
     */
41 View Code Duplication
    public function createCategoryElement(\DomDocument $document, CategoryInterface $category)
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in 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...
42
    {
43
        $element = $document->createElement($this->getNodeName());
44
        $element->setAttribute('scheme', $category->getScheme());
45
        $element->setAttribute('term', $category->getTerm());
46
        $element->setAttribute('label', $category->getLabel());
47
        
48
        return $element;
49
    }
50
}
51