You've already forked php-flasher
mirror of
https://github.com/php-flasher/php-flasher.git
synced 2026-04-06 13:02:55 +01:00
47 lines
920 B
PHP
47 lines
920 B
PHP
<?php
|
|
|
|
namespace Flasher\Prime\Filter\Specification;
|
|
|
|
use Flasher\Prime\Envelope;
|
|
|
|
final class HopsSpecification implements SpecificationInterface
|
|
{
|
|
/**
|
|
* @var int
|
|
*/
|
|
private $minAmount;
|
|
|
|
/**
|
|
* @var int|null
|
|
*/
|
|
private $maxAmount;
|
|
|
|
/**
|
|
* @param int $minAmount
|
|
* @param int|null $maxAmount
|
|
*/
|
|
public function __construct($minAmount, $maxAmount = null)
|
|
{
|
|
$this->minAmount = $minAmount;
|
|
$this->maxAmount = $maxAmount;
|
|
}
|
|
|
|
/**
|
|
* @inheritDoc
|
|
*/
|
|
public function isSatisfiedBy(Envelope $envelope)
|
|
{
|
|
$stamp = $envelope->get('Flasher\Prime\Stamp\HopsStamp');
|
|
|
|
if (null === $stamp) {
|
|
return false;
|
|
}
|
|
|
|
if (null !== $this->maxAmount && $stamp->getAmount() > $this->maxAmount) {
|
|
return false;
|
|
}
|
|
|
|
return $stamp->getAmount() >= $this->minAmount;
|
|
}
|
|
}
|