for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
/*
* This file is part of the Borobudur-Config package.
*
* (c) Hexacodelabs <http://hexacodelabs.com>
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Borobudur\Config;
/**
* @author Iqbal Maulana <[email protected]>
* @created 8/13/15
trait MinMaxValueValidatorTrait
{
* Check if min or max value is valid.
* @param string $type (min|max)
* @param int|float $value
* @param string $operator
* @return bool
protected function isValid($type, $value, $operator = null)
$operator = $operator ?: $type;
if (isset($this->{$type})) {
return $this->compute($operator, $type, $value);
}
return true;
private function compute($operator, $type, $value)
switch ($operator) {
case 'min':
return $value < $this->{$type};
case 'max':
return $value > $this->{$type};