Create::getData()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 2
Bugs 1 Features 0
Metric Value
c 2
b 1
f 0
dl 0
loc 4
rs 10
cc 1
eloc 2
nc 1
nop 0
1
<?php
2
3
namespace Pin\Card;
4
5
use Pin\RequestInterface;
6
use Symfony\Component\OptionsResolver\OptionsResolver;
7
8
class Create implements RequestInterface
9
{
10
    protected $options;
11
12
    public function __construct(array $options = array())
13
    {
14
        $resolver = new OptionsResolver();
15
        $this->setDefaultOptions($resolver);
16
17
        $this->options = $resolver->resolve($options);
18
    }
19
20
    protected function setDefaultOptions(OptionsResolver $resolver)
21
    {
22
        $resolver
23
            ->setRequired(array(
24
                'number',
25
                'expiry_month',
26
                'expiry_year',
27
                'cvc',
28
                'name',
29
                'address_line1',
30
                'address_city',
31
                'address_postcode',
32
                'address_state',
33
                'address_country'
34
            ))
35
            ->setAllowedTypes('number', 'numeric')
36
            ->setAllowedTypes('expiry_month', 'numeric')
37
            ->setAllowedTypes('expiry_year', 'numeric')
38
            ->setAllowedTypes('cvc', 'numeric')
39
            ->setAllowedTypes('name', 'string')
40
            ->setAllowedTypes('address_line1', 'string')
41
            ->setAllowedTypes('address_city', 'string')
42
            ->setAllowedTypes('address_postcode', 'numeric')
43
            ->setAllowedTypes('address_state', 'string')
44
            ->setAllowedTypes('address_country', 'string')
45
        ;
46
    }
47
48
    /**
49
     * {@inheritdoc}
50
     */
51
    public function getMethod()
52
    {
53
        return self::METHOD_POST;
54
    }
55
56
    /**
57
     * {@inheritdoc}
58
     */
59
    public function getPath()
60
    {
61
        return '/1/cards';
62
    }
63
64
    /**
65
     * {@inheritdoc}
66
     */
67
    public function getData()
68
    {
69
        return $this->options;
70
    }
71
}
72