Create   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 64
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Importance

Changes 3
Bugs 1 Features 0
Metric Value
wmc 5
c 3
b 1
f 0
lcom 0
cbo 1
dl 0
loc 64
rs 10

5 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 7 1
B setDefaultOptions() 0 27 1
A getMethod() 0 4 1
A getPath() 0 4 1
A getData() 0 4 1
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