Create::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 7
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 7
rs 9.4285
cc 1
eloc 4
nc 1
nop 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