AbstractPriorityToken::__toString()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
cc 1
nc 1
nop 0
dl 0
loc 4
ccs 2
cts 2
cp 1
crap 1
rs 10
c 0
b 0
f 0
1
<?php
2
declare(strict_types=1);
3
4
namespace Moka\Plugin\Prophecy\Token;
5
6
use Prophecy\Argument\Token\TokenInterface;
7
use Prophecy\Prophecy\ObjectProphecy;
8
9
/**
10
 * Class AbstractPriorityToken
11
 * @package Moka\Plugin\Prophecy\Token
12
 */
13
abstract class AbstractPriorityToken implements TokenInterface
14
{
15
    /**
16
     * @var int
17
     */
18
    private $salt;
19
20
    /**
21
     * MaxPriorityToken constructor.
22
     */
23 22
    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 22
        $this->salt = mt_rand();
32
    }
33
34
    /**
35
     * @param $argument
36
     * @return int
37
     */
38 7
    public function scoreArgument($argument): int
39
    {
40 7
        return $this->getPriority();
41
    }
42
43
    /**
44
     * @return int
45
     */
46
    abstract protected function getPriority(): int;
47
48
    /**
49
     * @return bool
50
     */
51 6
    public function isLast(): bool
52
    {
53 6
        return true;
54
    }
55
56
    /**
57
     * @return string
58
     */
59 1
    public function __toString()
60
    {
61 1
        return \get_class($this);
62
    }
63
}
64