2016-04-04 20:25:27 +00:00
|
|
|
<?php
|
2016-04-04 20:49:54 +00:00
|
|
|
|
2016-11-20 21:53:17 +00:00
|
|
|
declare(strict_types=1);
|
2016-04-04 20:25:27 +00:00
|
|
|
|
|
|
|
namespace Phpml\Exception;
|
|
|
|
|
|
|
|
class InvalidArgumentException extends \Exception
|
|
|
|
{
|
2017-11-06 07:56:37 +00:00
|
|
|
public static function arraySizeNotMatch() : InvalidArgumentException
|
2016-04-04 20:25:27 +00:00
|
|
|
{
|
2017-05-17 07:03:25 +00:00
|
|
|
return new self('Size of given arrays does not match');
|
2016-04-04 20:25:27 +00:00
|
|
|
}
|
2016-04-06 20:38:08 +00:00
|
|
|
|
2017-11-06 07:56:37 +00:00
|
|
|
public static function percentNotInRange($name) : InvalidArgumentException
|
2016-04-06 20:38:08 +00:00
|
|
|
{
|
|
|
|
return new self(sprintf('%s must be between 0.0 and 1.0', $name));
|
|
|
|
}
|
2016-04-27 21:04:59 +00:00
|
|
|
|
2017-11-06 07:56:37 +00:00
|
|
|
public static function arrayCantBeEmpty() : InvalidArgumentException
|
2016-04-27 21:04:59 +00:00
|
|
|
{
|
|
|
|
return new self('The array has zero elements');
|
|
|
|
}
|
|
|
|
|
2017-11-06 07:56:37 +00:00
|
|
|
public static function arraySizeToSmall(int $minimumSize = 2) : InvalidArgumentException
|
2016-04-27 21:04:59 +00:00
|
|
|
{
|
2017-09-02 20:44:19 +00:00
|
|
|
return new self(sprintf('The array must have at least %d elements', $minimumSize));
|
2016-04-27 21:04:59 +00:00
|
|
|
}
|
2016-04-29 22:58:54 +00:00
|
|
|
|
2017-11-06 07:56:37 +00:00
|
|
|
public static function matrixDimensionsDidNotMatch() : InvalidArgumentException
|
2016-04-29 22:58:54 +00:00
|
|
|
{
|
|
|
|
return new self('Matrix dimensions did not match');
|
|
|
|
}
|
|
|
|
|
2017-11-06 07:56:37 +00:00
|
|
|
public static function inconsistentMatrixSupplied() : InvalidArgumentException
|
2016-04-29 22:58:54 +00:00
|
|
|
{
|
2017-05-17 07:03:25 +00:00
|
|
|
return new self('Inconsistent matrix supplied');
|
2016-04-29 22:58:54 +00:00
|
|
|
}
|
2016-05-01 21:17:09 +00:00
|
|
|
|
2017-11-06 07:56:37 +00:00
|
|
|
public static function invalidClustersNumber() : InvalidArgumentException
|
2016-05-01 21:17:09 +00:00
|
|
|
{
|
|
|
|
return new self('Invalid clusters number');
|
|
|
|
}
|
2016-06-14 09:53:58 +00:00
|
|
|
|
2017-05-17 22:07:14 +00:00
|
|
|
/**
|
2017-07-26 06:22:12 +00:00
|
|
|
* @param mixed $target
|
2017-05-17 22:07:14 +00:00
|
|
|
*/
|
2017-11-06 07:56:37 +00:00
|
|
|
public static function invalidTarget($target) : InvalidArgumentException
|
2017-05-17 22:07:14 +00:00
|
|
|
{
|
2017-09-02 20:44:19 +00:00
|
|
|
return new self(sprintf('Target with value "%s" is not part of the accepted classes', $target));
|
2017-05-17 22:07:14 +00:00
|
|
|
}
|
|
|
|
|
2017-11-06 07:56:37 +00:00
|
|
|
public static function invalidStopWordsLanguage(string $language) : InvalidArgumentException
|
2016-06-14 09:53:58 +00:00
|
|
|
{
|
2017-09-02 20:44:19 +00:00
|
|
|
return new self(sprintf('Can\'t find "%s" language for StopWords', $language));
|
2016-06-14 09:53:58 +00:00
|
|
|
}
|
2016-08-05 08:20:31 +00:00
|
|
|
|
2017-11-06 07:56:37 +00:00
|
|
|
public static function invalidLayerNodeClass() : InvalidArgumentException
|
2016-08-05 08:20:31 +00:00
|
|
|
{
|
|
|
|
return new self('Layer node class must implement Node interface');
|
|
|
|
}
|
2016-08-09 11:27:43 +00:00
|
|
|
|
2017-11-06 07:56:37 +00:00
|
|
|
public static function invalidLayersNumber() : InvalidArgumentException
|
2016-08-09 11:27:43 +00:00
|
|
|
{
|
2017-05-17 22:07:14 +00:00
|
|
|
return new self('Provide at least 1 hidden layer');
|
2016-08-09 11:27:43 +00:00
|
|
|
}
|
2017-05-17 22:07:14 +00:00
|
|
|
|
2017-11-06 07:56:37 +00:00
|
|
|
public static function invalidClassesNumber() : InvalidArgumentException
|
2017-05-17 22:07:14 +00:00
|
|
|
{
|
|
|
|
return new self('Provide at least 2 different classes');
|
|
|
|
}
|
|
|
|
|
2017-11-06 07:56:37 +00:00
|
|
|
public static function inconsistentClasses() : InvalidArgumentException
|
2017-05-23 07:03:05 +00:00
|
|
|
{
|
|
|
|
return new self('The provided classes don\'t match the classes provided in the constructor');
|
|
|
|
}
|
2017-09-02 20:44:19 +00:00
|
|
|
|
2017-11-06 07:56:37 +00:00
|
|
|
public static function fileNotFound(string $file) : InvalidArgumentException
|
2017-09-02 20:44:19 +00:00
|
|
|
{
|
|
|
|
return new self(sprintf('File "%s" not found', $file));
|
|
|
|
}
|
|
|
|
|
2017-11-06 07:56:37 +00:00
|
|
|
public static function fileNotExecutable(string $file) : InvalidArgumentException
|
2017-09-02 20:44:19 +00:00
|
|
|
{
|
|
|
|
return new self(sprintf('File "%s" is not executable', $file));
|
|
|
|
}
|
|
|
|
|
2017-11-06 07:56:37 +00:00
|
|
|
public static function pathNotFound(string $path) : InvalidArgumentException
|
2017-09-02 20:44:19 +00:00
|
|
|
{
|
|
|
|
return new self(sprintf('The specified path "%s" does not exist', $path));
|
|
|
|
}
|
|
|
|
|
2017-11-06 07:56:37 +00:00
|
|
|
public static function pathNotWritable(string $path) : InvalidArgumentException
|
2017-09-02 20:44:19 +00:00
|
|
|
{
|
|
|
|
return new self(sprintf('The specified path "%s" is not writable', $path));
|
|
|
|
}
|
2017-10-24 16:59:12 +00:00
|
|
|
|
2017-11-06 07:56:37 +00:00
|
|
|
public static function invalidOperator(string $operator) : InvalidArgumentException
|
2017-10-24 16:59:12 +00:00
|
|
|
{
|
|
|
|
return new self(sprintf('Invalid operator "%s" provided', $operator));
|
|
|
|
}
|
2016-04-04 20:25:27 +00:00
|
|
|
}
|