for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
namespace BestServedCold\PhalueObjects\Mathematical\Operator;
use BestServedCold\PhalueObjects\Contract\ValueObject as ValueObjectInterface;
/**
* Class ComparisonTrait
*
* @package BestServedCold\PhalueObjects\Mathematical\Operator
* @author Adam Lewis <[email protected]>
* @copyright Copyright (c) 2015 Best Served Cold Media Limited
* @license http://http://opensource.org/licenses/GPL-3.0 GPL License
* @link http://bestservedcold.com
* @since 0.0.1-alpha
* @version 0.0.2-alpha
*/
trait ComparisonTrait
{
* @return int
public abstract function getValue();
* @param ValueObjectInterface $object
* @return bool
public function isGreaterThan(ValueObjectInterface $object)
return $this->getValue() > $object->getValue();
}
public function isLessThan(ValueObjectInterface $object)
return $this->getValue() < $object->getValue();
public function isGreaterThanOrEqualTo(ValueObjectInterface $object)
return $this->getValue() >= $object->getValue();
public function isLessThanOrEqualTo(ValueObjectInterface $object)
return $this->getValue() <= $object->getValue();
public function spaceship(ValueObjectInterface $object)
return ($this->getValue() < $object->getValue())
? -1
: (
($this->getValue() > $object->getValue())
? 1
: 0
);