| 1 | <?php |
||
| 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 |
|
| 55 | |||
| 56 | /** |
||
| 57 | * @return string |
||
| 58 | */ |
||
| 59 | 1 | public function __toString() |
|
| 63 | } |
||
| 64 |