1
0
Fork 0
mirror of synced 2024-05-20 12:42:39 +12:00
appwrite/src/Appwrite/Storage/Validator/FileSize.php
Eldad A. Fux 042660b15c
Feat psalm analysis (#699)
* Added static code analysis
* Updated code to solve psalm issue
2020-10-27 02:08:29 +02:00

49 lines
791 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;
}
}