Validate/File/Size.php

Show: PublicProtectedPrivateinherited
Table of Contents
Zend Framework
LICENSE This source file is subject to the new BSD license that is bundled with this package in the file LICENSE.txt. It is also available through the world-wide-web at this URL: http://framework.zend.com/license/new-bsd If you did not receive a copy of the license and are unable to obtain it through the world-wide-web, please send an email to license@zend.com so we can send you a copy immediately.
Category
Zend  
Copyright
Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com)  
License
New BSD License  
Package
Zend_Validate  
Version
$Id$  

\Zend_Validate_File_Size

Package: Zend_Validate
Validator for the maximum size of a file up to a max of 2GB
Parent(s)
\Zend_Validate_Abstract
Children
\Zend_Validate_File_FilesSize
Category
Zend  
Copyright
Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com)  
License
New BSD License  

Constants

>VConstant  TOO_BIG = 'fileSizeTooBig'
>VConstant  TOO_SMALL = 'fileSizeTooSmall'
>VConstant  NOT_FOUND = 'fileSizeNotFound'

Properties

>VPropertyprotectedinteger|null $_max
Maximum filesize
If null, there is no maximum filesize
Details
Type
integer | null
>VPropertyprotectedarray $_messageTemplates = array(self::TOO_BIG => "Maximum allowed size for file '%value%' is '%max%' but '%size%' detected", self::TOO_SMALL => "Minimum expected size for file '%value%' is '%min%' but '%size%' detected", self::NOT_FOUND => "File '%value%' is not readable or does not exist")

Error message templates

Default valuearray(self::TOO_BIG => "Maximum allowed size for file '%value%' is '%max%' but '%size%' detected", self::TOO_SMALL => "Minimum expected size for file '%value%' is '%min%' but '%size%' detected", self::NOT_FOUND => "File '%value%' is not readable or does not exist")Details
Type
array
>VPropertyprotectedarray $_messageVariables = array('min' => '_min', 'max' => '_max', 'size' => '_size')

Error message template variables

Default valuearray('min' => '_min', 'max' => '_max', 'size' => '_size')Details
Type
array
>VPropertyprotectedinteger $_min
Minimum filesize
Details
Type
integer
>VPropertyprotectedinteger $_size
Detected size
Details
Type
integer
>VPropertyprotectedboolean $_useByteString = true
Use bytestring ?
Default valuetrueDetails
Type
boolean

Methods

methodpublic__construct(integer | array $options) : void

Sets validator options

If $options is a integer, it will be used as maximum filesize As Array is accepts the following keys: 'min': Minimum filesize 'max': Maximum filesize 'bytestring': Use bytestring or real size for messages
Parameters
NameTypeDescription
$optionsinteger | array

Options for the adapter

methodprotected_fromByteString(string $size) : integer

Returns the unformatted size

Parameters
NameTypeDescription
$sizestring
Returns
TypeDescription
integer
methodprotected_getSize() : int

Retrieve current detected file size

Returns
TypeDescription
int
methodprotected_setSize(int $size) : \Zend_Validate_File_Size

Set current size

Parameters
NameTypeDescription
$sizeint
Returns
TypeDescription
\Zend_Validate_File_Size
methodprotected_throw(string $file, string $errorType) : false

Throws an error of the given type

Parameters
NameTypeDescription
$filestring
$errorTypestring
Returns
TypeDescription
false
methodprotected_toByteString(integer $size) : string

Returns the formatted size

Parameters
NameTypeDescription
$sizeinteger
Returns
TypeDescription
string
methodpublicgetMax(bool $raw = false) : integer | string

Returns the maximum filesize

Parameters
NameTypeDescription
$rawbool

Whether or not to force return of the raw value (defaults off)

Returns
TypeDescription
integer | string
methodpublicgetMin(bool $raw = false) : integer | string

Returns the minimum filesize

Parameters
NameTypeDescription
$rawbool

Whether or not to force return of the raw value (defaults off)

Returns
TypeDescription
integer | string
methodpublicisValid(string $value, array $file = null) : boolean

Defined by Zend_Validate_Interface

Returns true if and only if the filesize of $value is at least min and not bigger than max (when max is not null).
Parameters
NameTypeDescription
$valuestring

Real file to check for size

$filearray

File data from Zend_File_Transfer

Returns
TypeDescription
boolean
methodpublicsetMax(integer $max) : \Zend_Validate_StringLength

Sets the maximum filesize

Parameters
NameTypeDescription
$maxinteger

The maximum filesize

Returns
TypeDescription
\Zend_Validate_StringLengthProvides a fluent interface
Throws
ExceptionDescription
\Zend_Validate_ExceptionWhen max is smaller than min
methodpublicsetMin(integer $min) : \Zend_Validate_File_Size

Sets the minimum filesize

Parameters
NameTypeDescription
$mininteger

The minimum filesize

Returns
TypeDescription
\Zend_Validate_File_SizeProvides a fluent interface
Throws
ExceptionDescription
\Zend_Validate_ExceptionWhen min is greater than max
methodpublicsetUseByteString(boolean $byteString = true) : integer

Returns the minimum filesize

Parameters
NameTypeDescription
$byteStringboolean

Use bytestring ?

Returns
TypeDescription
integer
methodpublicuseByteString() : boolean

Will bytestring be used?

Returns
TypeDescription
boolean
Documentation was generated by phpDocumentor 2.2.0 .