Create   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 53
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 53
rs 10

5 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 7 1
A setDefaultOptions() 0 16 1
A getMethod() 0 4 1
A getPath() 0 4 1
A getData() 0 4 1
1
<?php
2
3
namespace Pin\Customer;
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
                'email'
25
            ))
26
            ->setDefined(array(
27
                'ip_address',
28
                'card',
29
                'card_token'
30
            ))
31
            ->setAllowedTypes('email', 'string')
32
            ->setAllowedTypes('card', 'array')
33
            ->setAllowedTypes('card_token', 'string')
34
        ;
35
    }
36
37
    /**
38
     * {@inheritdoc}
39
     */
40
    public function getMethod()
41
    {
42
        return self::METHOD_POST;
43
    }
44
45
    /**
46
     * {@inheritdoc}
47
     */
48
    public function getPath()
49
    {
50
        return '/1/customers';
51
    }
52
53
    /**
54
     * {@inheritdoc}
55
     */
56
    public function getData()
57
    {
58
        return $this->options;
59
    }
60
}
61