first commit
This commit is contained in:
52
vendor/php-flasher/flasher/Stamp/PriorityStamp.php
vendored
Normal file
52
vendor/php-flasher/flasher/Stamp/PriorityStamp.php
vendored
Normal file
@ -0,0 +1,52 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the PHPFlasher package.
|
||||
* (c) Younes KHOUBZA <younes.khoubza@gmail.com>
|
||||
*/
|
||||
|
||||
namespace Flasher\Prime\Stamp;
|
||||
|
||||
final class PriorityStamp implements StampInterface, OrderableStampInterface, PresentableStampInterface
|
||||
{
|
||||
/**
|
||||
* @var int
|
||||
*/
|
||||
private $priority;
|
||||
|
||||
/**
|
||||
* @param int $priority
|
||||
*/
|
||||
public function __construct($priority)
|
||||
{
|
||||
$this->priority = $priority;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function getPriority()
|
||||
{
|
||||
return $this->priority;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function compare($orderable)
|
||||
{
|
||||
if (!$orderable instanceof self) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
return $this->priority - $orderable->priority;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function toArray()
|
||||
{
|
||||
return array('priority' => $this->getPriority());
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user