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) |
|
|
|
|
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
|
|
|
|
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.