RemoveSigner::getValidationConstraints()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 12
Code Lines 9

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 9
dl 0
loc 12
c 0
b 0
f 0
rs 9.9666
cc 1
nc 1
nop 0
1
<?php
2
namespace Dokobit\Gateway\Query\Signing;
3
4
use Dokobit\Gateway\Query\QueryInterface;
5
use Dokobit\Gateway\Result\ResultInterface;
6
use Dokobit\Gateway\Result\Signing\RemoveSignerResult;
7
use Dokobit\Gateway\Validator\Constraints as MyAssert;
8
use Symfony\Component\Validator\Constraints as Assert;
9
10
/**
11
 * Remove signers from signing.
12
 * @see https://gateway-sandbox.dokobit.com/api/doc#_api_signing_removesigner
13
 */
14
class RemoveSigner implements QueryInterface
15
{
16
    /** @var string signing token */
17
    private $token;
18
19
    /** @var array information about document signers */
20
    private $signers;
21
22
    /**
23
     * @param string $token signing token
24
     * @param array $signers information about document signers
25
     */
26
    public function __construct(
27
        string $token,
28
        array $signers
29
    ) {
30
        $this->token = $token;
31
        $this->signers = $signers;
32
    }
33
34
    /**
35
     * Field and values association used in query
36
     * @return array
37
     */
38
    public function getFields(): array
39
    {
40
        return [
41
            'token' => $this->token,
42
            'signers' => $this->signers,
43
        ];
44
    }
45
46
    /**
47
     * Validation constraints for request data validation
48
     * @return Assert\Collection
49
     */
50
    public function getValidationConstraints(): Assert\Collection
51
    {
52
        return new Assert\Collection([
53
            'token' => new Assert\Required([
54
                new Assert\NotBlank(),
55
            ]),
56
            'signers' => new Assert\Required([
57
                new Assert\NotBlank(),
58
                new Assert\All([
59
                    new Assert\Collection([
60
                        'id' => new Assert\Required([
61
                            new Assert\NotBlank(),
62
                        ]),
63
                    ]),
64
                ]),
65
            ]),
66
        ]);
67
    }
68
69
    /**
70
     * Result object for this query result
71
     * @return RemoveSignerResult
72
     */
73
    public function createResult(): ResultInterface
74
    {
75
        return new RemoveSignerResult();
76
    }
77
78
    /**
79
     * API action name, part of full API request url
80
     * @return string
81
     */
82
    public function getAction(): string
83
    {
84
        return "signing/{$this->token}/removesigner";
85
    }
86
87
    /**
88
     * HTTP method to use
89
     * @return string
90
     */
91
    public function getMethod(): string
92
    {
93
        return QueryInterface::POST;
94
    }
95
}
96