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.

ParameterResolver   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 63
Duplicated Lines 12.7 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

Changes 0
Metric Value
wmc 3
lcom 1
cbo 2
dl 8
loc 63
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A resolve() 0 6 1
A initResolver() 8 8 1
A initAllowed() 0 7 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
namespace Lexik\Bundle\PayboxBundle\Paybox\System\Cancellation;
4
5
use Lexik\Bundle\PayboxBundle\Paybox\AbstractParameterResolver;
6
7
/**
8
 * Class ParameterResolver
9
 *
10
 * @package Lexik\Bundle\PayboxBundle\Paybox\System\Cancellation
11
 *
12
 * @author Fabien Pomerol <[email protected]>
13
 */
14
class ParameterResolver extends AbstractParameterResolver
15
{
16
    /**
17
     * @var array
18
     */
19
    private $knownParameters = array(
20
        'VERSION',
21
        'TYPE',
22
        'SITE',
23
        'IDENTIFIANT',
24
        'MACH',
25
        'HMAC',
26
        'TIME',
27
        'ABONNEMENT',
28
        'REFERENCE',
29
    );
30
31
    /**
32
     * @var array
33
     */
34
    private $requiredParameters = array(
35
        'VERSION',
36
        'TYPE',
37
        'SITE',
38
        'IDENTIFIANT',
39
        'MACH',
40
        'HMAC',
41
        'TIME',
42
    );
43
44
    /**
45
     * {@inheritdoc}
46
     */
47
    public function resolve(array $parameters)
48
    {
49
        $this->initResolver();
50
51
        return $this->resolver->resolve($parameters);
52
    }
53
54
    /**
55
     * {@inheritdoc}
56
     */
57 View Code Duplication
    protected function initResolver()
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...
58
    {
59
        $this->resolver->setRequired($this->requiredParameters);
60
61
        $this->resolver->setDefined(array_diff($this->knownParameters, $this->requiredParameters));
62
63
        $this->initAllowed();
64
    }
65
66
    /**
67
     * Initialize allowed values for the cancellation OptionResolver.
68
     */
69
    protected function initAllowed()
70
    {
71
        $this->resolver
72
            ->setAllowedValues('VERSION', array('001'))
73
            ->setAllowedValues('TYPE', array('001'))
74
        ;
75
    }
76
}
77