GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.

NameTrait   A
last analyzed

Complexity

Total Complexity 6

Size/Duplication

Total Lines 45
Duplicated Lines 100 %

Coupling/Cohesion

Components 1
Dependencies 1

Test Coverage

Coverage 100%
Metric Value
wmc 6
lcom 1
cbo 1
dl 45
loc 45
ccs 10
cts 10
cp 1
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A getName() 4 4 1
A setName() 6 6 1
A parseName() 6 6 4

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
 * @link https://github.com/old-town/old-town-workflow
4
 * @author  Malofeykin Andrey  <[email protected]>
5
 */
6
namespace OldTown\Workflow\Loader\Traits;
7
8
use DOMElement;
9
use OldTown\Workflow\Loader\XmlUtil;
10
11
/**
12
 * Class ConditionDescriptor
13
 *
14
 * @package OldTown\Workflow\Loader
15
 */
16 View Code Duplication
trait NameTrait
0 ignored issues
show
Duplication introduced by
This class 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...
17
{
18
    /**
19
     * @var string
20
     */
21
   protected $name;
22
23
24
    /**
25
     * Возвращает имя
26
     *
27
     * @return string
28
     */
29 50
    public function getName()
30
    {
31 50
        return $this->name;
32
    }
33
34
    /**
35
     * Устанавливает имя
36
     *
37
     * @param $name
38
     *
39
     * @return $this
40
     */
41 1
    public function setName($name)
42
    {
43 1
        $this->name = $name;
44
45 1
        return $this;
46
    }
47
48
    /**
49
     * Парсит элемент и извлекает из имя
50
     *
51
     * @param DOMElement $element
52
     * @param bool       $flagRequired
53
     */
54 107
    protected function parseName(DOMElement $element, $flagRequired = false)
55
    {
56 107
        if ($flagRequired || (!$flagRequired && $element->hasAttribute('name'))) {
57 101
            $this->name = XmlUtil::getRequiredAttributeValue($element, 'name');
58 101
        }
59 107
    }
60
}
61