Passed
Pull Request — master (#18)
by Žilvinas
02:40
created

AbstractSmartIdQuery::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 7
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 7
ccs 4
cts 4
cp 1
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 5
nc 1
nop 2
crap 1
1
<?php
2
namespace Isign\Login;
3
4
use Isign\QueryInterface;
5
use Isign\Validator\Constraints\Code;
6
use Isign\Validator\Constraints\Phone;
7
use Symfony\Component\Validator\Constraints as Assert;
8
9
/**
10
 * Absctract smartId query.
11
 */
12
abstract class AbstractSmartIdQuery implements QueryInterface
13
{
14
    /** @var string user personal code */
15
    private $code;
16
17
    /** @var string Country related to personal code. Example EE */
18
    private $country;
19
20
    /**
21
     * @param string $code
22
     * @param string $country
23
     */
24 5
    public function __construct(
25
        $code,
26
        $country
27
    ) {
28 5
        $this->code = $code;
29 5
        $this->country = $country;
30 5
    }
31
32
    /**
33
     * Field and values association used in query
34
     * @return array
35
     */
36 1
    public function getFields()
37
    {
38
        $return = [
39 1
            'code' => $this->code,
40 1
            'country' => $this->country,
41
        ];
42
43 1
        return $return;
44
    }
45
46
    /**
47
     * Validation constraints for request data validation
48
     * @return Assert\Collection
49
     */
50 1 View Code Duplication
    public function getValidationConstraints()
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
51
    {
52 1
        return new Assert\Collection([
53 1
            'code' => new Assert\Required([
54 1
                new Assert\NotBlank(),
55 1
                new Code()
56
            ]),
57 1
            'country' => new Assert\Required([
58 1
                new Assert\NotBlank(),
59
            ]),
60
        ]);
61
    }
62
63
    /**
64
     * HTTP method to use
65
     * @return string
66
     */
67 1
    public function getMethod()
68
    {
69 1
        return QueryInterface::POST;
70
    }
71
}
72