for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
/**
* This file is part of the League.csv library
*
* @license http://opensource.org/licenses/MIT
* @link https://github.com/thephpleague/csv/
* @version 8.1.1
* @package League.csv
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace League\Csv\Config;
use InvalidArgumentException;
* A trait to configure and check CSV file and content
* @since 6.0.0
trait Validator
{
* Validate an integer
* @param int $int
* @param int $minValue
* @param string $errorMessage
* @throws InvalidArgumentException If the value is invalid
* @return int
protected static function validateInteger($int, $minValue, $errorMessage)
if (false === ($int = filter_var($int, FILTER_VALIDATE_INT, ['options' => ['min_range' => $minValue]]))) {
throw new InvalidArgumentException($errorMessage);
}
return $int;
* validate a string
* @param mixed $str the value to evaluate as a string
* @throws InvalidArgumentException if the submitted data can not be converted to string
* @return string
protected static function validateString($str)
if (is_string($str) || (is_object($str) && method_exists($str, '__toString'))) {
return (string) $str;
throw new InvalidArgumentException('Expected data must be a string or stringable');