Passed
Push — master ( c1f9a4...4b0053 )
by Rimas
02:42 queued 32s
created

CreateBatch   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 76
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 6
eloc 16
dl 0
loc 76
c 0
b 0
f 0
rs 10

6 Methods

Rating   Name   Duplication   Size   Complexity  
A createResult() 0 3 1
A __construct() 0 3 1
A getValidationConstraints() 0 10 1
A getFields() 0 7 1
A getMethod() 0 3 1
A getAction() 0 3 1
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\CreateBatchResult;
7
use Symfony\Component\Validator\Constraints as Assert;
8
9
/**
10
 * Create a batch signing.
11
 * @see https://gateway-sandbox.dokobit.com/api/doc#_api_signing_createbatch
12
 */
13
class CreateBatch implements QueryInterface
14
{
15
    /** @var array an array of associative arrays of signing and signer tokens */
16
    private $signings;
17
18
    /**
19
     * @param array $signings an array of associative arrays of signing and signer tokens. Format:
20
     *       [
21
     *           ['token' => 'signingToken1', 'signer_token' => 'signerToken1'],
22
     *           ['token' => 'signingToken2', 'signer_token' => 'signerToken2'],
23
     *           ...
24
     *       ]
25
     */
26
    public function __construct(array $signings)
27
    {
28
        $this->signings = $signings;
29
    }
30
31
    /**
32
     * Field and values association used in query
33
     * @return array
34
     */
35
    public function getFields(): array
36
    {
37
        $return = [
38
            'signings' => $this->signings,
39
        ];
40
41
        return $return;
42
    }
43
44
    /**
45
     * Validation constraints for request data validation
46
     * @return Assert\Collection
47
     */
48
    public function getValidationConstraints(): Assert\Collection
49
    {
50
        return new Assert\Collection([
51
            'signings' => new Assert\All([
52
                new Assert\Collection([
53
                    'token' => new Assert\Required([
54
                        new Assert\NotBlank()
55
                    ]),
56
                    'signer_token' => new Assert\Optional([
57
                        new Assert\NotBlank(),
58
                    ]),
59
                ]),
60
            ]),
61
        ]);
62
    }
63
64
    /**
65
     * Result object for this query result
66
     * @return CreateBatchResult
67
     */
68
    public function createResult(): ResultInterface
69
    {
70
        return new CreateBatchResult();
71
    }
72
73
    /**
74
     * API action name, part of full API request url
75
     * @return string
76
     */
77
    public function getAction(): string
78
    {
79
        return 'signing/createbatch';
80
    }
81
82
    /**
83
     * HTTP method to use
84
     * @return string
85
     */
86
    public function getMethod(): string
87
    {
88
        return QueryInterface::POST;
89
    }
90
}
91