Moved UnitTests to tests/ and Skills to src/

This commit is contained in:
Alexander Liljengård
2016-05-24 13:53:56 +02:00
parent 11b5033c8a
commit 4ab0c5d719
64 changed files with 0 additions and 0 deletions

62
src/Numerics/Range.php Normal file
View File

@ -0,0 +1,62 @@
<?php
namespace Moserware\Numerics;
// The whole purpose of this class is to make the code for the SkillCalculator(s)
// look a little cleaner
class Range
{
private $_min;
private $_max;
public function __construct($min, $max)
{
if ($min > $max)
{
throw new Exception("min > max");
}
$this->_min = $min;
$this->_max = $max;
}
public function getMin()
{
return $this->_min;
}
public function getMax()
{
return $this->_max;
}
protected static function create($min, $max)
{
return new Range($min, $max);
}
// REVIEW: It's probably bad form to have access statics via a derived class, but the syntax looks better :-)
public static function inclusive($min, $max)
{
return static::create($min, $max);
}
public static function exactly($value)
{
return static::create($value, $value);
}
public static function atLeast($minimumValue)
{
return static::create($minimumValue, PHP_INT_MAX );
}
public function isInRange($value)
{
return ($this->_min <= $value) && ($value <= $this->_max);
}
}
?>