mirror of
https://github.com/furyfire/trueskill.git
synced 2025-03-20 16:48:04 +00:00
First TwoPlayerTrueSkillCalculator unit test passed
This commit is contained in:
35
PHPSkills/Guard.php
Normal file
35
PHPSkills/Guard.php
Normal file
@ -0,0 +1,35 @@
|
||||
<?php
|
||||
namespace Moserware\Skills;
|
||||
|
||||
/// <summary>
|
||||
/// Verifies argument contracts.
|
||||
/// </summary>
|
||||
/// <remarks>These are used until .NET 4.0 ships with Contracts. For more information,
|
||||
/// see http://www.moserware.com/2008/01/borrowing-ideas-from-3-interesting.html</remarks>
|
||||
class Guard
|
||||
{
|
||||
public static function argumentNotNull($value, $parameterName)
|
||||
{
|
||||
if ($value == null)
|
||||
{
|
||||
throw new Exception($parameterName . " can not be null");
|
||||
}
|
||||
}
|
||||
|
||||
public static function argumentIsValidIndex($index, $count, $parameterName)
|
||||
{
|
||||
if (($index < 0) || ($index >= $count))
|
||||
{
|
||||
throw new Exception($parameterName . " is an invalid index");
|
||||
}
|
||||
}
|
||||
|
||||
public static function argumentInRangeInclusive($value, $min, $max, $parameterName)
|
||||
{
|
||||
if (($value < $min) || ($value > $max))
|
||||
{
|
||||
throw new Exception($parameterName . " is not in the valid range [" . $min . ", " . $max . "]");
|
||||
}
|
||||
}
|
||||
}
|
||||
?>
|
Reference in New Issue
Block a user