Measure/Number.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-2012 Zend Technologies USA Inc. (http://www.zend.com)  
License
New BSD License  
Package
Zend_Measure  
Version
$Id: Number.php 24593 2012-01-05 20:35:02Z matthew $  

\Zend_Measure_Number

Package: Zend\Measure\Zend\Measure\Number
Class for handling number conversions

This class can only handle numbers without precision

Parent(s)
\Zend_Measure_Abstract
Category
Zend  
Copyright
Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)  
License
New BSD License  

Constants

>VConstant  STANDARD = 'DECIMAL'
>VConstant  BINARY = 'BINARY'
>VConstant  TERNARY = 'TERNARY'
>VConstant  QUATERNARY = 'QUATERNARY'
>VConstant  QUINARY = 'QUINARY'
>VConstant  SENARY = 'SENARY'
>VConstant  SEPTENARY = 'SEPTENARY'
>VConstant  OCTAL = 'OCTAL'
>VConstant  NONARY = 'NONARY'
>VConstant  DECIMAL = 'DECIMAL'
>VConstant  DUODECIMAL = 'DUODECIMAL'
>VConstant  HEXADECIMAL = 'HEXADECIMAL'
>VConstant  ROMAN = 'ROMAN'

Properties

>VPropertyprotectedstring $_locale = null
inherited
Locale identifier
Inherited from: \Zend_Measure_Abstract::$$_locale
Default valuenullDetails
Type
string
Inherited_from
\Zend_Measure_Abstract::$$_locale  
>VPropertyprivatearray $_roman = array('I' => 1, 'A' => 4, 'V' => 5, 'B' => 9, 'X' => 10, 'E' => 40, 'L' => 50, 'F' => 90, 'C' => 100, 'G' => 400, 'D' => 500, 'H' => 900, 'M' => 1000, 'J' => 4000, 'P' => 5000, 'K' => 9000, 'Q' => 10000, 'N' => 40000, 'R' => 50000, 'W' => 90000, 'S' => 100000, 'Y' => 400000, 'T' => 500000, 'Z' => 900000, 'U' => 1000000)
static
Definition of all roman signs
Default valuearray('I' => 1, 'A' => 4, 'V' => 5, 'B' => 9, 'X' => 10, 'E' => 40, 'L' => 50, 'F' => 90, 'C' => 100, 'G' => 400, 'D' => 500, 'H' => 900, 'M' => 1000, 'J' => 4000, 'P' => 5000, 'K' => 9000, 'Q' => 10000, 'N' => 40000, 'R' => 50000, 'W' => 90000, 'S' => 100000, 'Y' => 400000, 'T' => 500000, 'Z' => 900000, 'U' => 1000000)Details
Type
array
>VPropertyprivatearray $_romanconvert = array('/_V/' => '/P/', '/_X/' => '/Q/', '/_L/' => '/R/', '/_C/' => '/S/', '/_D/' => '/T/', '/_M/' => '/U/', '/IV/' => '/A/', '/IX/' => '/B/', '/XL/' => '/E/', '/XC/' => '/F/', '/CD/' => '/G/', '/CM/' => '/H/', '/M_V/' => '/J/', '/MQ/' => '/K/', '/QR/' => '/N/', '/QS/' => '/W/', '/ST/' => '/Y/', '/SU/' => '/Z/')
static
Convertion table for roman signs
Default valuearray('/_V/' => '/P/', '/_X/' => '/Q/', '/_L/' => '/R/', '/_C/' => '/S/', '/_D/' => '/T/', '/_M/' => '/U/', '/IV/' => '/A/', '/IX/' => '/B/', '/XL/' => '/E/', '/XC/' => '/F/', '/CD/' => '/G/', '/CM/' => '/H/', '/M_V/' => '/J/', '/MQ/' => '/K/', '/QR/' => '/N/', '/QS/' => '/W/', '/ST/' => '/Y/', '/SU/' => '/Z/')Details
Type
array
>VPropertyprotectedstring $_type
inherited
Original type for this unit
Inherited from: \Zend_Measure_Abstract::$$_type
Details
Type
string
Inherited_from
\Zend_Measure_Abstract::$$_type  
>VPropertyprotectedarray $_units = array('BINARY' => array(2, '⑵'), 'TERNARY' => array(3, '⑶'), 'QUATERNARY' => array(4, '⑷'), 'QUINARY' => array(5, '⑸'), 'SENARY' => array(6, '⑹'), 'SEPTENARY' => array(7, '⑺'), 'OCTAL' => array(8, '⑻'), 'NONARY' => array(9, '⑼'), 'DECIMAL' => array(10, '⑽'), 'DUODECIMAL' => array(12, '⑿'), 'HEXADECIMAL' => array(16, '⒃'), 'ROMAN' => array(99, ''), 'STANDARD' => 'DECIMAL')
Calculations for all number units
Default valuearray('BINARY' => array(2, '⑵'), 'TERNARY' => array(3, '⑶'), 'QUATERNARY' => array(4, '⑷'), 'QUINARY' => array(5, '⑸'), 'SENARY' => array(6, '⑹'), 'SEPTENARY' => array(7, '⑺'), 'OCTAL' => array(8, '⑻'), 'NONARY' => array(9, '⑼'), 'DECIMAL' => array(10, '⑽'), 'DUODECIMAL' => array(12, '⑿'), 'HEXADECIMAL' => array(16, '⒃'), 'ROMAN' => array(99, ''), 'STANDARD' => 'DECIMAL')Details
Type
array
>VPropertyprotectedstring $_value
inherited
Plain value in standard unit
Inherited from: \Zend_Measure_Abstract::$$_value
Details
Type
string
Inherited_from
\Zend_Measure_Abstract::$$_value  

Methods

methodpublic__construct(integer $value, string $type, string | \Zend_Locale $locale = null) : void

Zend_Measure_Abstract is an abstract class for the different measurement types

Parameters
NameTypeDescription
$valueinteger

Value

$typestring

(Optional) A Zend_Measure_Number Type

$localestring | \Zend_Locale

(Optional) A Zend_Locale

Throws
ExceptionDescription
\Zend_Measure_ExceptionWhen language is unknown
\Zend_Measure_ExceptionWhen type is unknown
methodpublic__toString() : string
inherited

Returns a string representation

Inherited from: \Zend_Measure_Abstract::__toString()
Returns
TypeDescription
string
methodprivate_fromDecimal(integer $value, string $type) : string

Convert input to type value string

Parameters
NameTypeDescription
$valueinteger

Input string

$typestring

Type to convert to

Returns
TypeDescription
string
Throws
ExceptionDescription
\Zend_Measure_ExceptionWhen more than 200 digits are calculated
methodprivate_toDecimal(integer $input, string $type) : string

Convert input to decimal value string

Parameters
NameTypeDescription
$inputinteger

Input string

$typestring

Type from which to convert to decimal

Returns
TypeDescription
string
methodpublicadd(\Zend_Measure_Abstract $object) : \Zend_Measure_Abstract
inherited

Adds an unit to another one

Inherited from: \Zend_Measure_Abstract::add()
Parameters
NameTypeDescription
$object\Zend_Measure_Abstract

object of same unit type

Returns
TypeDescription
\Zend_Measure_Abstract
methodpubliccompare(\Zend_Measure_Abstract $object) : boolean
inherited

Compares two units

Inherited from: \Zend_Measure_Abstract::compare()
Parameters
NameTypeDescription
$object\Zend_Measure_Abstract

object of same unit type

Returns
TypeDescription
boolean
methodpublicconvertTo(string $type, integer $round = 0,  $locale = null) : string

Alias function for setType returning the converted unit Default is 0 as this class only handles numbers without precision

Parameters
NameTypeDescription
$typestring

Type to convert to

$roundinteger

(Optional) Precision to add, will always be 0

$locale
Returns
TypeDescription
string
methodpublicequals(\Zend_Measure_Abstract $object) : boolean
inherited

Compare if the value and type is equal

Inherited from: \Zend_Measure_Abstract::equals()
Parameters
NameTypeDescription
$object\Zend_Measure_Abstract

object to compare

Returns
TypeDescription
boolean
methodpublicgetConversionList() : array
inherited

Returns the conversion list

Inherited from: \Zend_Measure_Abstract::getConversionList()
Returns
TypeDescription
array
methodpublicgetLocale() : string
inherited

Returns the actual set locale

Inherited from: \Zend_Measure_Abstract::getLocale()
Returns
TypeDescription
string
methodpublicgetType() : \type
inherited

Returns the original type

Inherited from: \Zend_Measure_Abstract::getType()
Returns
TypeDescription
\type
methodpublicgetValue(integer $round = -1, string | \Zend_Locale $locale = null) : integer | string
inherited

Returns the internal value

Inherited from: \Zend_Measure_Abstract::getValue()
Parameters
NameTypeDescription
$roundinteger

(Optional) Rounds the value to an given precision, Default is -1 which returns without rounding

$localestring | \Zend_Locale

(Optional) Locale for number representation

Returns
TypeDescription
integer | string
methodpublicsetLocale(string | \Zend_Locale $locale = null, boolean $check = false) : \Zend_Measure_Abstract
inherited

Sets a new locale for the value representation

Inherited from: \Zend_Measure_Abstract::setLocale()
Parameters
NameTypeDescription
$localestring | \Zend_Locale

(Optional) New locale to set

$checkboolean

False, check but don't set; True, set the new locale

Returns
TypeDescription
\Zend_Measure_Abstract
methodpublicsetType(string $type) : void

Set a new type, and convert the value

Parameters
NameTypeDescription
$typestring

New type to set

Throws
ExceptionDescription
\Zend_Measure_ExceptionWhen a unknown type is given
methodpublicsetValue(integer $value, string $type = null, string | \Zend_Locale $locale = null) : \Zend_Measure_Abstract

Set a new value

Parameters
NameTypeDescription
$valueinteger

Value

$typestring

(Optional) A Zend_Measure_Number Type

$localestring | \Zend_Locale

(Optional) A Zend_Locale Type

Returns
TypeDescription
\Zend_Measure_Abstract
Throws
ExceptionDescription
\Zend_Measure_Exception
methodpublicsub(\Zend_Measure_Abstract $object) : \Zend_Measure_Abstract
inherited

Substracts an unit from another one

Inherited from: \Zend_Measure_Abstract::sub()
Parameters
NameTypeDescription
$object\Zend_Measure_Abstract

object of same unit type

Returns
TypeDescription
\Zend_Measure_Abstract
methodpublictoString(integer $round = -1, string | \Zend_Locale $locale = null) : string
inherited

Returns a string representation

Inherited from: \Zend_Measure_Abstract::toString()
Parameters
NameTypeDescription
$roundinteger

(Optional) Runds the value to an given exception

$localestring | \Zend_Locale

(Optional) Locale to set for the number

Returns
TypeDescription
string
Documentation was generated by phpDocumentor 2.0.0a12.