Verification   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 43
Duplicated Lines 0 %

Importance

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

2 Methods

Rating   Name   Duplication   Size   Complexity  
A resolveOutput() 0 19 1
A resolveInput() 0 14 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\Endpoint;
15
use Mediapart\LaPresseLibre\Subscription\Type as SubscriptionType;
16
use Symfony\Component\OptionsResolver\OptionsResolver;
17
18
/**
19
 * @see https://github.com/NextINpact/LaPresseLibreSDK/wiki/Fonctionnement-des-web-services#web-service-de-v%C3%A9rification-de-comptes-existants
20
 */
21
class Verification extends Endpoint
22
{
23
    /**
24
     * {@inheritdoc}
25
     */
26
    protected function resolveInput(array $arguments)
27
    {
28
        $resolver = new OptionsResolver();
29
        $resolver->setDefaults([
30
            'Mail' => null,
31
            'Password' => null,
32
        ]);
33
34
        $resolver->setRequired('CodeUtilisateur');
35
        $resolver->setAllowedTypes('Mail', ['string', 'null']);
36
        $resolver->setAllowedTypes('Password', ['string', 'null']);
37
        $resolver->setAllowedTypes('CodeUtilisateur', 'string');
38
39
        return $resolver->resolve($arguments);
40
    }
41
42
    /**
43
     * {@inheritdoc}
44
     */
45
    protected function resolveOutput(array $data)
46
    {
47
        $resolver = new OptionsResolver();
48
        $resolver->setDefaults([
49
            'TypeAbonnement' => null,
50
            'DateExpiration' => null,
51
            'DateSouscription' => null,
52
        ]);
53
54
        $resolver->setRequired(['Mail', 'CodeUtilisateur', 'AccountExist', 'PartenaireID']);
55
        $resolver->setAllowedTypes('Mail', 'string');
56
        $resolver->setAllowedTypes('CodeUtilisateur', 'string');
57
        $resolver->setAllowedValues('TypeAbonnement', array_merge(SubscriptionType::all(), [null]));
58
        $resolver->setAllowedTypes('DateExpiration', ['string', 'null']);
59
        $resolver->setAllowedTypes('DateSouscription', ['string', 'null']);
60
        $resolver->setAllowedTypes('AccountExist', ['boolean']);
61
        $resolver->setAllowedTypes('PartenaireID', 'int');
62
63
        return $resolver->resolve($data);
64
    }
65
}
66