Passed
Push — master ( 66db8b...8cd4fd )
by Žilvinas
41s
created

AbstractStatus::getValidationConstraints()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 8
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 8
ccs 4
cts 4
cp 1
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 4
nc 1
nop 0
crap 1
1
<?php
2
namespace Isign\Login;
3
4
use Isign\QueryInterface;
5
use Isign\TokenizedQueryInterface;
6
use Symfony\Component\Validator\Constraints as Assert;
7
8
/**
9
 * Login status for MobileId, SmartId, etc.
10
 */
11
abstract class AbstractStatus implements TokenizedQueryInterface
12
{
13
    /** @var string unique resource identifier, received from mobile login request */
14
    protected $token;
15
16
    /**
17
     * @param string $token unique resource identifier, received from mobile login request
18
     */
19 28
    public function __construct($token)
20
    {
21 28
        $this->token = $token;
22 28
    }
23
24
    /**
25
     * Get token
26
     * @return string
27
     */
28 4
    public function getToken()
29
    {
30 4
        return $this->token;
31
    }
32
33
    /**
34
     * Get fields
35
     * @return array
36
     */
37 4
    public function getFields()
38
    {
39
        return [
40 4
            'token' => $this->token,
41
        ];
42
    }
43
44
    /**
45
     * Validation constraints for request data validation
46
     * @return Assert\Collection
47
     */
48 4
    public function getValidationConstraints()
49
    {
50 4
        return new Assert\Collection([
51 4
            'token' => new Assert\Required(
52 4
                [new Assert\NotBlank()]
53
            )
54
        ]);
55
    }
56
57
    /**
58
     * HTTP method to use
59
     * @return string
60
     */
61 4
    public function getMethod()
62
    {
63 4
        return QueryInterface::GET;
64
    }
65
}
66