Completed
Push — master ( b79065...3491b2 )
by
unknown
09:59
created

Create::getMethod()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 0
1
<?php
2
3
namespace Cardinity\Method\VoidPayment;
4
5
use Cardinity\Method\MethodInterface;
6
use Symfony\Component\Validator\Constraints as Assert;
7
8
class Create implements MethodInterface
9
{
10
    private $paymentId;
11
    private $description;
12
13
    public function __construct($paymentId, $description = null)
14
    {
15
        $this->paymentId = $paymentId;
16
        $this->description = $description;
17
    }
18
19
    public function getAction()
20
    {
21
        return sprintf('payments/%s/voids', $this->paymentId);
22
    }
23
24
    public function getMethod()
25
    {
26
        return MethodInterface::POST;
27
    }
28
29
    public function getAttributes()
30
    {
31
        $return = [];
32
33
        if ($this->description !== null) {
34
            $return['description'] = $this->description;
35
        }
36
37
        return $return;
38
    }
39
40
    public function createResultObject()
41
    {
42
        return new VoidPayment();
43
    }
44
45
    public function getValidationConstraints()
46
    {
47
        return new Assert\Collection([
48
            'description' => new Assert\Optional([
49
                new Assert\Type(['type' => 'string']),
50
                new Assert\Length([
51
                    'max' => 255
52
                ]),
53
            ]),
54
        ]);
55
    }
56
}
57