blueshoes php application framework and cms            core_util
[ class tree: core_util ] [ index: core_util ] [ all elements ]

Class: Bs_UnitConverter

Source Location: /core/util/Bs_UnitConverter.class.php

Class Overview

Bs_Object
   |
   --Bs_UnitConverter

Pseudostatic utility class to convert units.


Author(s):

Version:

  • 4.3.$Revision: 1.3 $ $Date: 2003/10/29 17:48:43 $

Copyright:

  • blueshoes.org

Methods


Inherited Variables

Inherited Methods

Class: Bs_Object

Bs_Object::Bs_Object()
Bs_Object::getErrors()
Basic error handling: Get *all* errors as string array from the global Bs_Error-error stack.
Bs_Object::getLastError()
Basic error handling: Get last error string from the global Bs_Error-error stack.
Bs_Object::getLastErrors()
Basic error handling: Get last errors string array from the global Bs_Error-error stack sinc last call of getLastErrors().
Bs_Object::persist()
Persists this object by serializing it and saving it to a file with unique name.
Bs_Object::setError()
Basic error handling: Push an error string on the global Bs_Error-error stack.
Bs_Object::toHtml()
Dumps the content of this object to a string using PHP's var_dump().
Bs_Object::toString()
Dumps the content of this object to a string using PHP's var_dump().
Bs_Object::unpersist()
Fetches an object that was persisted with persist()

Class Details

[line 36]
Pseudostatic utility class to convert units.

dependencies: none.

source: i've collected information from the web, especially from http://www.digitaldutch.com/unitconverter/ i don't think you can copyright the relations of units to each other or their names. so there cannot be a license violation.




Tags:

pattern:  singleton: (pseudostatic)
access:  public
version:  4.3.$Revision: 1.3 $ $Date: 2003/10/29 17:48:43 $
copyright:  blueshoes.org
author:  andrej arn <at blueshoes dot org>


[ Top ]


Class Methods


constructor Bs_UnitConverter [line 39]

Bs_UnitConverter Bs_UnitConverter( )



[ Top ]

method bitsAndBytes [line 198]

string bitsAndBytes( string $from, string $to, string $value, [int $round = 2])

converts bits, bytes etc.

can convert the following units: bits, bytes, kilobits, kilobytes, megabits, megabytes, gigabits, gigabytes, terabits, terabytes, petabits, petabytes, exabits, exabytes




Parameters:

string   $from  
string   $to  
string   $value  
int   $round   (default is 2, since bs4.3)

[ Top ]

method length [line 82]

string length( string $from, string $to, string $value, [int $precision = 3])

converts length.

can convert the following units (alphabetic listing): +---------------+------------------------------------+ | KEY | DESCRIPTION | +---------------+------------------------------------+ | cables | | | cm | centimeters | | chains | chains (surveyors) | | dm | decimeters | | ells | elles (UK) | | fathoms | | | feet | feet (UK and US) | | furlongs | | | hands | | | hm | hectometers | | inches | | | km | kilometers | | m | meters | | miles | miles (UK and US) | | milesNautical | miles (nautical) | | mm | millimeters | | yards | | +---------------+------------------------------------+

not implemented but relations known: ångströms [Å], astronomical units [AU], barleycorns, ems (pica), feet (US survey), light years, micrometers, parsecs, picometers.




Tags:

throws:  FALSE (on unknown/misspelled units)


Parameters:

string   $from   (see key above)
string   $to   (see key above)
string   $value  
int   $precision   to round. Using PHP's round() func.

[ Top ]

method temperature [line 139]

string temperature( string $from, string $to, string $value, [int $precision = 3])

converts temperature.

can convert the following units: celsius, fahrenheit, kelvin, rankine, réaumure




Tags:

throws:  FALSE (on unknown/misspelled units)


Parameters:

string   $from  
string   $to  
string   $value  
int   $precision   to round. Using PHP's round() func.

[ Top ]

method toUsefulBitAndByteString [line 228]

string toUsefulBitAndByteString( mixed $bytes)

takes a number of bytes and converts it to a useful string.

eg (todo)




Parameters:

mixed   $bytes   (numeric, can be string int double)

[ Top ]

method unitStringToBytes [line 284]

int unitStringToBytes( mixed $unitStr, mixed $newBufSize)

Takes a string with unit (200KB, 1.2M, 0.23G, ...) and converts it to bytes (int or float)

Acceped units (case insensitive): K,M,G,T,P,E and KB,MB,GB,TB,PB,EB PARAM: If numeric we assume it as absolute byte size. If string it may end with 'k' or 'M' (for kilo-,Mega-byte) OR '%' If ending with '%' this means use x% of the available memory as given by memory_limit in the php.ini file. But we never exeed 80%.




Tags:

return:  The set buffersize in byte.
throws:  FALSE on error. (Buffer size is left unchanged)


Parameters:

mixed   $newBufSize   (see above)

[ Top ]


Documentation generated on Mon, 29 Dec 2003 21:13:13 +0100 by phpDocumentor 1.2.3