1
0
Fork 0
mirror of synced 2024-06-03 03:14:50 +12:00
appwrite/src/Appwrite/Storage/Validator/FileSize.php
2020-10-27 21:44:15 +02:00

49 lines
792 B
PHP

<?php
namespace Appwrite\Storage\Validator;
use Utopia\Validator;
class FileSize extends Validator
{
/**
* @var int
*/
protected $max;
/**
* Max size in bytes
*
* @param int $max
*/
public function __construct($max)
{
$this->max = $max;
}
public function getDescription()
{
return 'File size can\'t be bigger than '.$this->max;
}
/**
* Finds whether a file size is smaller than required limit.
*
* @param mixed $fileSize
*
* @return bool
*/
public function isValid($fileSize)
{
if (!is_int($fileSize)) {
return false;
}
if ($fileSize > $this->max) {
return false;
}
return true;
}
}