本文整理匯總了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);
}