1
0
Fork 0
mirror of synced 2024-05-21 05:02:37 +12:00
appwrite/src/Appwrite/Storage/Validator/FileSize.php
2020-07-19 18:17:57 +03:00

45 lines
711 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 int $fileSize
*
* @return bool
*/
public function isValid($fileSize)
{
if ($fileSize > $this->max) {
return false;
}
return true;
}
}