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.

HelperLocator   A
last analyzed

Complexity

Total Complexity 6

Size/Duplication

Total Lines 49
Duplicated Lines 100 %

Coupling/Cohesion

Components 0
Dependencies 2

Importance

Changes 4
Bugs 1 Features 0
Metric Value
wmc 6
c 4
b 1
f 0
lcom 0
cbo 2
dl 49
loc 49
rs 10

5 Methods

Rating   Name   Duplication   Size   Complexity  
A getPriority() 4 4 1
A isSupported() 4 4 1
A getResource() 7 7 2
A getClassType() 4 4 1
A getValidator() 4 4 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
 * MageSpec
4
 *
5
 * NOTICE OF LICENSE
6
 *
7
 * This source file is subject to the MIT License, that is bundled with this
8
 * package in the file LICENSE.
9
 * It is also available through the world-wide-web at this URL:
10
 *
11
 * http://opensource.org/licenses/MIT
12
 *
13
 * If you did not receive a copy of the license and are unable to obtain it
14
 * through the world-wide-web, please send an email
15
 * to <[email protected]> so we can send you a copy immediately.
16
 *
17
 * @category   MageTest
18
 * @package    PhpSpec_MagentoExtension
19
 *
20
 * @copyright  Copyright (c) 2012-2013 MageTest team and contributors.
21
 */
22
namespace MageTest\PhpSpec\MagentoExtension\Locator\Magento;
23
24
use PhpSpec\Locator\ResourceLocator as ResourceLocatorInterface;
25
26
/**
27
 * HelperLocator
28
 *
29
 * @category   MageTest
30
 * @package    PhpSpec_MagentoExtension
31
 *
32
 * @author     MageTest team (https://github.com/MageTest/MageSpec/contributors)
33
 */
34 View Code Duplication
class HelperLocator extends AbstractResourceLocator implements ResourceLocatorInterface
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...
35
{
36
    /**
37
     * @return int
38
     */
39
    public function getPriority()
40
    {
41
        return 20;
42
    }
43
44
    /**
45
     * @param string $file
46
     * @return bool
47
     */
48
    protected function isSupported($file)
49
    {
50
        return strpos($file, 'Helper') > 0;
51
    }
52
53
    /**
54
     * @param array $parts
55
     * @param ResourceLocatorInterface $locator
56
     * @return HelperResource
57
     * @throws \InvalidArgumentException
58
     */
59
    protected function getResource(array $parts, ResourceLocatorInterface $locator)
60
    {
61
        if (!$locator instanceof HelperLocator) {
62
            throw new \InvalidArgumentException('Helper resource requires a helper locator');
63
        }
64
        return new HelperResource($parts, $locator);
65
    }
66
67
    /**
68
     * @return string
69
     */
70
    protected function getClassType()
71
    {
72
        return 'Helper';
73
    }
74
75
    /**
76
     * @return string
77
     */
78
    protected function getValidator()
79
    {
80
        return '/^(helper):([a-zA-Z0-9]+)_([a-zA-Z0-9]+)\/([a-zA-Z0-9]+)(_[\w]+)?$/';
81
    }
82
}
83