AccountUpdate   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 47
Duplicated Lines 36.17 %

Importance

Changes 0
Metric Value
wmc 2
dl 17
loc 47
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A resolveInput() 0 20 1
A resolveOutput() 17 17 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
/**
4
 * This file is part of the Mediapart LaPresseLibre Library.
5
 *
6
 * CC BY-NC-SA <https://github.com/mediapart/lapresselibre>
7
 *
8
 * For the full license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
12
namespace Mediapart\LaPresseLibre\Operation;
13
14
use Mediapart\LaPresseLibre\Subscription\Type as SubscriptionType;
15
use Mediapart\LaPresseLibre\Subscription\Status as SubscriptionStatus;
16
use Symfony\Component\OptionsResolver\OptionsResolver;
17
18
/**
19
 * @see https://github.com/NextINpact/LaPresseLibreSDK/wiki/Fonctionnement-des-web-services#web-service-de-mise-%C3%A0-jour-de-comptes
20
 */
21
class AccountUpdate extends AccountChange
22
{
23
    /**
24
     * {@inheritdoc}
25
     */
26
    protected function resolveInput(array $arguments)
27
    {
28
        $resolver = new OptionsResolver();
29
        $resolver->setRequired([
30
            'CodeUtilisateur',
31
            'TypeAbonnement',
32
            'DateSouscription',
33
            'DateExpiration',
34
            'Tarif',
35
            'Statut',
36
        ]);
37
38
        $resolver->setAllowedTypes('CodeUtilisateur', 'string');
39
        $resolver->setAllowedTypes('TypeAbonnement', 'string');
40
        $resolver->setAllowedTypes('Tarif', 'float');
41
        $resolver->setAllowedTypes('Statut', 'int');
42
        $resolver->setAllowedValues('TypeAbonnement', SubscriptionType::all());
43
        $resolver->setAllowedValues('Statut', SubscriptionStatus::all());
44
45
        return $resolver->resolve($arguments);
46
    }
47
48
    /**
49
     * {@inheritdoc}
50
     */
51 View Code Duplication
    protected function resolveOutput(array $data)
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...
52
    {
53
        $resolver = new OptionsResolver();
54
        $resolver->setRequired([
55
            'IsValid',
56
            'PartenaireID',
57
            'CodeUtilisateur',
58
            'CodeEtat',
59
        ]);
60
61
        $resolver->setAllowedTypes('IsValid', 'bool');
62
        $resolver->setAllowedTypes('PartenaireID', 'int');
63
        $resolver->setAllowedTypes('CodeUtilisateur', 'string');
64
        $resolver->setAllowedTypes('CodeEtat', 'int');
65
        $resolver->setAllowedValues('CodeEtat', self::allStates());
66
67
        return $resolver->resolve($data);
68
    }
69
}
70