Class TypeUtils

Description

Collection of methods to deal with variables and data types (casting, conversion, sanity check)

Located in /core/util/TypeUtils.class.php (line 37)

PHP2Go
   |
   --TypeUtils
Method Summary
static string getType (mixed $value)
static mixed ifFalse (mixed $value, [mixed $default = FALSE])
static mixed ifNull (mixed $value, [mixed $default = NULL])
static bool isArray (mixed $value)
static bool isBoolean (mixed $value)
static bool isEmpty (mixed $value)
static bool isFalse (mixed $value)
static bool isFloat (mixed &$value, [bool $strict = FALSE])
static bool isHashArray (mixed $value)
static bool isInstanceOf (object $object, string $className, [string $recurse = TRUE])
static bool isInteger (mixed &$value, [bool $strict = FALSE])
static bool isNull (mixed $value, [bool $strict = FALSE])
static bool isObject (mixed $value)
static mixed isResource (mixed $value)
static bool isString (mixed $value)
static bool isTrue (mixed $value)
static float parseFloat (mixed $value)
static float parseFloatPositive (mixed $value)
static int parseInteger (mixed $value)
static int parseIntegerPositive (mixed $value)
static string parseString (mixed $value)
static array toArray (mixed $value)
static bool toBoolean (mixed $value)
Methods
static method getType (line 46)

Get the type of a given value

  • return: Type
static string getType (mixed $value)
  • mixed $value: Value
static method ifFalse (line 338)

Returns a "default" value when a given value is FALSE

static mixed ifFalse (mixed $value, [mixed $default = FALSE])
  • mixed $value: Value to be tested
  • mixed $default: Default value, when $value is FALSE
static method ifNull (line 291)

Returns a "default" value when a given value is NULL

static mixed ifNull (mixed $value, [mixed $default = NULL])
  • mixed $value: Value to be tested
  • mixed $default: Default value, when $value is NULL
static method isArray (line 178)

Checks if a given value is an array

static bool isArray (mixed $value)
  • mixed $value: Value to be tested
static method isBoolean (line 304)

Checks if a value is boolean

static bool isBoolean (mixed $value)
  • mixed $value: Value to be tested
static method isEmpty (line 362)

Checks if a value is empty

static bool isEmpty (mixed $value)
  • mixed $value: Value to be tested
static method isFalse (line 326)

Checks if a value is FALSE

static bool isFalse (mixed $value)
  • mixed $value: Value to be tested
static method isFloat (line 62)

Determines if a given value is float

If $strict is set to FALSE, a string value that is written in a valid float format, will be accepted and converted to float.

static bool isFloat (mixed &$value, [bool $strict = FALSE])
  • mixed &$value: Value to be tested
  • bool $strict: Strong or weak test
static method isHashArray (line 194)

Checks if a given value is a hash array

Even having numeric keys, an array that contains gaps in the indexes sequence can be considered a hash array. Non-integer keys, obviously, also represent hash arrays.

static bool isHashArray (mixed $value)
  • mixed $value: Value to be tested
static method isInstanceOf (line 242)

Checks if an object is instance of a given class

The $className argument is case-sensitive. Under PHP4, it will be converted to lowercase before the comparison.

static bool isInstanceOf (object $object, string $className, [string $recurse = TRUE])
  • object $object: Object
  • string $className: Class name
  • string $recurse: Whether parent classes should be considered
static method isInteger (line 115)

Checks if a given value is integer

If $strict is set to FALSE, a string written as a valid integer number will be accepted and converted to int.

static bool isInteger (mixed &$value, [bool $strict = FALSE])
  • mixed &$value: Value to be tested
  • bool $strict: Strong or weak test
static method isNull (line 279)

Checks if a value is NULL

When $strict is set to FALSE, a simple value comparison is made. Otherwise, the datatype will also be considered.

static bool isNull (mixed $value, [bool $strict = FALSE])
  • mixed $value: Value to be tested
  • bool $strict: Strong or weak test
static method isObject (line 226)

Checks if a given value is an object

static bool isObject (mixed $value)
  • mixed $value: Value to be tested
static method isResource (line 261)

Checks if a given value is a resource

Returns the resource type in case of success.

static mixed isResource (mixed $value)
  • mixed $value: Value to be tested
static method isString (line 156)

Checks if a given value is a string

static bool isString (mixed $value)
  • mixed $value: Value to be tested
static method isTrue (line 315)

Checks if a value is TRUE

static bool isTrue (mixed $value)
  • mixed $value: Value to be tested
static method parseFloat (line 83)

Converts a given value to float

static float parseFloat (mixed $value)
  • mixed $value: Value
static method parseFloatPositive (line 100)

Converts the given value to a positive floating point number

static float parseFloatPositive (mixed $value)
  • mixed $value: Value
static method parseInteger (line 134)

Converts a given value to integer

static int parseInteger (mixed $value)
  • mixed $value: Input value
static method parseIntegerPositive (line 145)

Converts a given value into a positive integer number

static int parseIntegerPositive (mixed $value)
  • mixed $value: Input value
static method parseString (line 167)

Converts a given value into a string

static string parseString (mixed $value)
  • mixed $value: Input value
static method toArray (line 215)

Converts a given value to array

static array toArray (mixed $value)
  • mixed $value: Input value
static method toBoolean (line 351)

Converts a value to boolean

static bool toBoolean (mixed $value)
  • mixed $value: Input value

Inherited Methods

Inherited From PHP2Go

PHP2Go::PHP2Go()
PHP2Go::equals()
PHP2Go::generateUniqueId()
PHP2Go::getClassName()
PHP2Go::getConfigVal()
PHP2Go::getLangVal()
PHP2Go::getObjectName()
PHP2Go::getParentName()
PHP2Go::hasDestructor()
PHP2Go::hashCode()
PHP2Go::isA()
PHP2Go::isSubclassOf()
PHP2Go::logError()
PHP2Go::raiseError()
PHP2Go::registerDestructor()
PHP2Go::registerShutdownFunc()
PHP2Go::retrieve()
PHP2Go::store()
PHP2Go::__toString()

Documentation generated on Sun, 07 Oct 2007 19:30:48 -0300 by phpDocumentor 1.3.2