Cleanup in src/, adding namespaces, removing php closing tag and general code cleanup

This commit is contained in:
Alexander Liljengård
2016-05-24 14:10:39 +02:00
parent 9f97eb1653
commit 5694a2fb30
64 changed files with 891 additions and 1328 deletions

View File

@@ -1,35 +1,32 @@
<?php
namespace Moserware\Skills;
<?php namespace Moserware\Skills;
use Exception;
/**
* Verifies argument contracts.
*
*
* @see http://www.moserware.com/2008/01/borrowing-ideas-from-3-interesting.html
*/
class Guard
{
public static function argumentNotNull($value, $parameterName)
{
if ($value == null)
{
if ($value == null) {
throw new Exception($parameterName . " can not be null");
}
}
public static function argumentIsValidIndex($index, $count, $parameterName)
{
if (($index < 0) || ($index >= $count))
{
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))
{
if (($value < $min) || ($value > $max)) {
throw new Exception($parameterName . " is not in the valid range [" . $min . ", " . $max . "]");
}
}
}
?>
}