mirror of
https://github.com/Llewellynvdm/php-ml.git
synced 2024-06-06 10:30:48 +00:00
726cf4cddf
* travis: move coveralls here, decouple from package * composer: use PSR4 * phpunit: simpler config * travis: add ecs run * composer: add ecs dev * use standard vendor/bin directory for dependency bins, confuses with local bins and require gitignore handling * ecs: add PSR2 * [cs] PSR2 spacing fixes * [cs] PSR2 class name fix * [cs] PHP7 fixes - return semicolon spaces, old rand functions, typehints * [cs] fix less strict typehints * fix typehints to make tests pass * ecs: ignore typehint-less elements * [cs] standardize arrays * [cs] standardize docblock, remove unused comments * [cs] use self where possible * [cs] sort class elements, from public to private * [cs] do not use yoda (found less yoda-cases, than non-yoda) * space * [cs] do not assign in condition * [cs] use namespace imports if possible * [cs] use ::class over strings * [cs] fix defaults for arrays properties, properties and constants single spacing * cleanup ecs comments * [cs] use item per line in multi-items array * missing line * misc * rebase
104 lines
2.8 KiB
PHP
104 lines
2.8 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace Phpml\Exception;
|
|
|
|
use Exception;
|
|
|
|
class InvalidArgumentException extends Exception
|
|
{
|
|
public static function arraySizeNotMatch(): self
|
|
{
|
|
return new self('Size of given arrays does not match');
|
|
}
|
|
|
|
public static function percentNotInRange($name): self
|
|
{
|
|
return new self(sprintf('%s must be between 0.0 and 1.0', $name));
|
|
}
|
|
|
|
public static function arrayCantBeEmpty(): self
|
|
{
|
|
return new self('The array has zero elements');
|
|
}
|
|
|
|
public static function arraySizeToSmall(int $minimumSize = 2): self
|
|
{
|
|
return new self(sprintf('The array must have at least %d elements', $minimumSize));
|
|
}
|
|
|
|
public static function matrixDimensionsDidNotMatch(): self
|
|
{
|
|
return new self('Matrix dimensions did not match');
|
|
}
|
|
|
|
public static function inconsistentMatrixSupplied(): self
|
|
{
|
|
return new self('Inconsistent matrix supplied');
|
|
}
|
|
|
|
public static function invalidClustersNumber(): self
|
|
{
|
|
return new self('Invalid clusters number');
|
|
}
|
|
|
|
/**
|
|
* @param mixed $target
|
|
*/
|
|
public static function invalidTarget($target): self
|
|
{
|
|
return new self(sprintf('Target with value "%s" is not part of the accepted classes', $target));
|
|
}
|
|
|
|
public static function invalidStopWordsLanguage(string $language): self
|
|
{
|
|
return new self(sprintf('Can\'t find "%s" language for StopWords', $language));
|
|
}
|
|
|
|
public static function invalidLayerNodeClass(): self
|
|
{
|
|
return new self('Layer node class must implement Node interface');
|
|
}
|
|
|
|
public static function invalidLayersNumber(): self
|
|
{
|
|
return new self('Provide at least 1 hidden layer');
|
|
}
|
|
|
|
public static function invalidClassesNumber(): self
|
|
{
|
|
return new self('Provide at least 2 different classes');
|
|
}
|
|
|
|
public static function inconsistentClasses(): self
|
|
{
|
|
return new self('The provided classes don\'t match the classes provided in the constructor');
|
|
}
|
|
|
|
public static function fileNotFound(string $file): self
|
|
{
|
|
return new self(sprintf('File "%s" not found', $file));
|
|
}
|
|
|
|
public static function fileNotExecutable(string $file): self
|
|
{
|
|
return new self(sprintf('File "%s" is not executable', $file));
|
|
}
|
|
|
|
public static function pathNotFound(string $path): self
|
|
{
|
|
return new self(sprintf('The specified path "%s" does not exist', $path));
|
|
}
|
|
|
|
public static function pathNotWritable(string $path): self
|
|
{
|
|
return new self(sprintf('The specified path "%s" is not writable', $path));
|
|
}
|
|
|
|
public static function invalidOperator(string $operator): self
|
|
{
|
|
return new self(sprintf('Invalid operator "%s" provided', $operator));
|
|
}
|
|
}
|