Completed
Push — master ( 7790b0...e2925f )
by Alberto
16s
created

AbstractPriorityToken::scoreArgument()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 4
ccs 2
cts 2
cp 1
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 1
crap 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 20
    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 20
        $this->salt = rand();
32
    }
33
34
    /**
35
     * @param $argument
36
     * @return int
37
     */
38 5
    public function scoreArgument($argument)
39
    {
40 5
        return $this->getPriority();
41
    }
42
43
    /**
44
     * @return bool
45
     */
46 4
    public function isLast()
47
    {
48 4
        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