API Documentation

Zend/Validate/File/Size.php

Show: inherited
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-2012 Zend Technologies USA Inc. (http://www.zend.com)  
License
New BSD License  
Package
Zend_Validate  
Version
$Id: Size.php 24594 2012-01-05 21:27:01Z matthew $  

\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-2012 Zend Technologies USA Inc. (http://www.zend.com)  
License
New BSD License  

Constants

Constant  TOO_BIG = 'fileSizeTooBig'
Constant  TOO_SMALL = 'fileSizeTooSmall'
Constant  NOT_FOUND = 'fileSizeNotFound'

Properties

Propertyprotectedinteger|null  $_max= ''

Maximum filesize

If null, there is no maximum filesize

Details
Type
integernull
Propertyprotectedarray  $_messageTemplates= 'array( self::TOO_BIG => "Maximum allowed size for file '%value%' is '%max%' but '%size%' detected"'

Error message templates
Default valuearray( self::TOO_BIG => "Maximum allowed size for file '%value%' is '%max%' but '%size%' detected"Details
Type
array
Propertyprotectedarray  $_messageVariables= 'array( 'min' => '_min''

Error message template variables
Default valuearray( 'min' => '_min'Details
Type
array
Propertyprotectedinteger  $_min= ''

Minimum filesize

Details
Type
integer
Propertyprotectedinteger  $_size= ''

Detected size

Details
Type
integer
Propertyprotectedboolean  $_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
Name Type Description
$options integer|array

Options for the adapter

methodprotected_fromByteString( string $size ) : integer

Returns the unformatted size

Parameters
Name Type Description
$size string
Returns
Type Description
integer
methodprotected_getSize( ) : int

Retrieve current detected file size

Returns
Type Description
int
methodprotected_setSize( int $size ) : \Zend_Validate_File_Size

Set current size

Parameters
Name Type Description
$size int
Returns
Type Description
\Zend_Validate_File_Size
methodprotected_throw( string $file, string $errorType ) : false

Throws an error of the given type

Parameters
Name Type Description
$file string
$errorType string
Returns
Type Description
false
methodprotected_toByteString( integer $size ) : string

Returns the formatted size

Parameters
Name Type Description
$size integer
Returns
Type Description
string
methodpublicgetMax( bool $raw = false ) : integer|string

Returns the maximum filesize

Parameters
Name Type Description
$raw bool

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

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

Returns the minimum filesize

Parameters
Name Type Description
$raw bool

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

Returns
Type Description
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
Name Type Description
$value string

Real file to check for size

$file array

File data from Zend_File_Transfer

Returns
Type Description
boolean
methodpublicsetMax( integer $max ) : \Zend_Validate_StringLength

Sets the maximum filesize

Parameters
Name Type Description
$max integer

The maximum filesize

Returns
Type Description
\Zend_Validate_StringLength Provides a fluent interface
Throws
Exception Description
\Zend_Validate_Exception When max is smaller than min
methodpublicsetMin( integer $min ) : \Zend_Validate_File_Size

Sets the minimum filesize

Parameters
Name Type Description
$min integer

The minimum filesize

Returns
Type Description
\Zend_Validate_File_Size Provides a fluent interface
Throws
Exception Description
\Zend_Validate_Exception When min is greater than max
methodpublicsetUseByteString( boolean $byteString = true ) : integer

Returns the minimum filesize

Parameters
Name Type Description
$byteString boolean

Use bytestring ?

Returns
Type Description
integer
methodpublicuseByteString( ) : boolean

Will bytestring be used?

Returns
Type Description
boolean
Documentation was generated by DocBlox 0.15.1.