for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
namespace Prophecy\Argument\Token;
class DateTimeDeltaToken implements TokenInterface
{
/** @var \DateTime */
private $value;
/** @var integer */
private $delta;
public function __construct(\DateTime $value, $delta)
$this->value = $value;
$this->delta = $delta;
}
/**
* Calculates token match score for provided argument.
*
* @param $argument
* @return bool|int
*/
public function scoreArgument($argument)
if (!$argument instanceof \DateTime) {
return false;
return abs($argument->getTimestamp() - $this->value->getTimestamp()) < $this->delta;
* Returns true if this token prevents check of other tokens (is last one).
public function isLast()
* Returns string representation for token.
* @return string
public function __toString()
return sprintf('Date{%s}~%d', $this->value->format('Y-m-d H:i:s'), $this->delta);