AccountCreation::resolveInput()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 21
Code Lines 16

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 21
rs 9.3142
c 0
b 0
f 0
cc 1
eloc 16
nc 1
nop 1
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\Status as SubscriptionStatus;
15
use Symfony\Component\OptionsResolver\OptionsResolver;
16
17
/**
18
 *
19
 * @see https://github.com/NextINpact/LaPresseLibreSDK/wiki/Fonctionnement-des-web-services#web-service-de-cr%C3%A9ation-de-comptes
20
 */
21
class AccountCreation extends AccountChange
22
{
23
    /**
24
     * {@inheritdoc}
25
     */
26
    protected function resolveInput(array $arguments)
27
    {
28
        $resolver = new OptionsResolver();
29
        $resolver->setRequired([
30
            'Pseudo',
31
            'Mail',
32
            'Password',
33
            'TypeAbonnement',
34
            'DateSouscription',
35
            'DateExpiration',
36
            'Tarif',
37
            'CodeUtilisateur',
38
            'Statut',
39
        ]);
40
41
        $resolver->setAllowedTypes('Tarif', 'float');
42
        $resolver->setAllowedTypes('CodeUtilisateur', 'string');
43
        $resolver->setAllowedTypes('Statut', 'int');
44
        $resolver->setAllowedValues('Statut', SubscriptionStatus::all());
45
46
        return $resolver->resolve($arguments);
47
    }
48
49
    /**
50
     * {@inheritdoc}
51
     */
52 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...
53
    {
54
        $resolver = new OptionsResolver();
55
        $resolver->setRequired([
56
            'IsValid',
57
            'PartenaireID',
58
            'CodeUtilisateur',
59
            'CodeEtat',
60
        ]);
61
62
        $resolver->setAllowedTypes('IsValid', 'bool');
63
        $resolver->setAllowedTypes('PartenaireID', 'int');
64
        $resolver->setAllowedTypes('CodeUtilisateur', 'string');
65
        $resolver->setAllowedTypes('CodeEtat', 'int');
66
        $resolver->setAllowedValues('CodeEtat', self::allStates());
67
68
        return $resolver->resolve($data);
69
    }
70
}
71