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

AbstractStatus   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 55
Duplicated Lines 100 %

Coupling/Cohesion

Components 1
Dependencies 3

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 5
lcom 1
cbo 3
dl 55
loc 55
ccs 13
cts 13
cp 1
rs 10
c 0
b 0
f 0

5 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 4 4 1
A getToken() 4 4 1
A getFields() 6 6 1
A getValidationConstraints() 8 8 1
A getMethod() 4 4 1

How to fix   Duplicated Code   

Duplicated Code

Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.

Common duplication problems, and corresponding solutions are:

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 View Code Duplication
abstract class AbstractStatus implements TokenizedQueryInterface
0 ignored issues
show
Duplication introduced by
This class 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...
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