Completed
Push — master ( 9a0811...b72f37 )
by Angelo
15s
created

AbstractPriorityToken   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 51
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 4
lcom 0
cbo 0
dl 0
loc 51
ccs 8
cts 8
cp 1
rs 10
c 0
b 0
f 0

5 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 10 1
A scoreArgument() 0 4 1
A isLast() 0 4 1
A __toString() 0 4 1
getPriority() 0 1 ?
1
<?php
2
declare(strict_types=1);
3
4
namespace Moka\Strategy\Prophecy;
5
6
use Prophecy\Argument\Token\TokenInterface;
7
use Prophecy\Prophecy\ObjectProphecy;
8
9
/**
10
 * Class AbstractPriorityToken
11
 * @package Moka\Strategy\Prophecy
12
 */
13
abstract class AbstractPriorityToken implements TokenInterface
14
{
15
    /**
16
     * @var int
17
     */
18
    private $salt;
19
20
    /**
21
     * MaxPriorityToken constructor.
22
     */
23 24
    public function __construct()
24
    {
25
        /**
26
         * Ensure this instance won't match any other token instance when serialized ($priority isn't enough, as the
27
         * serialization just checks for its value without calling getPriority()).
28
         *
29
         * @see ObjectProphecy::__call()
30
         */
31 24
        $this->salt = rand();
32
    }
33
34
    /**
35
     * @param $argument
36
     * @return int
37
     */
38 6
    public function scoreArgument($argument)
39
    {
40 6
        return $this->getPriority();
41
    }
42
43
    /**
44
     * @return bool
45
     */
46 5
    public function isLast()
47
    {
48 5
        return true;
49
    }
50
51
    /**
52
     * @return string
53
     */
54 1
    public function __toString()
55
    {
56 1
        return '';
57
    }
58
59
    /**
60
     * @return int
61
     */
62
    abstract protected function getPriority(): int;
63
}
64