本文整理汇总了PHP中Cake\Utility\Text::parseFileSize方法的典型用法代码示例。如果您正苦于以下问题:PHP Text::parseFileSize方法的具体用法?PHP Text::parseFileSize怎么用?PHP Text::parseFileSize使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Cake\Utility\Text
的用法示例。
在下文中一共展示了Text::parseFileSize方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: __construct
/**
* Sets protected properties based on config provided
*
* @param array $config Configuration array
*/
public function __construct(array $config = [])
{
parent::__construct($config);
if (!empty($this->_config['path'])) {
$this->_path = $this->_config['path'];
}
if ($this->_path !== null && Configure::read('debug') && !is_dir($this->_path)) {
mkdir($this->_path, 0775, true);
}
if (!empty($this->_config['file'])) {
$this->_file = $this->_config['file'];
if (substr($this->_file, -4) !== '.log') {
$this->_file .= '.log';
}
}
if (!empty($this->_config['size'])) {
if (is_numeric($this->_config['size'])) {
$this->_size = (int) $this->_config['size'];
} else {
$this->_size = Text::parseFileSize($this->_config['size']);
}
}
}
示例2: fileSize
/**
* Checks the filesize
*
* @param string|array $check Value to check.
* @param string|null $operator See `Validation::comparison()`.
* @param int|string|null $size Size in bytes or human readable string like '5MB'.
* @return bool Success
*/
public static function fileSize($check, $operator = null, $size = null)
{
if (is_array($check) && isset($check['tmp_name'])) {
$check = $check['tmp_name'];
}
if (is_string($size)) {
$size = Text::parseFileSize($size);
}
$filesize = filesize($check);
return static::comparison($filesize, $operator, $size);
}
示例3: testparseFileSizeException
/**
* testparseFileSizeException
*
* @expectedException \InvalidArgumentException
* @return void
*/
public function testparseFileSizeException()
{
Text::parseFileSize('bogus', false);
}