Cradle  0.3.3
Simple library for creating Web-based applications
Data Class Reference

Data Class. More...

Static Public Member Functions

static load ($fileName, $stripXmlAttributes=true)
 
static set (&$destination, $source, $strict=false, $merge=false)
 
static setObject (&$destination, $source, $strict=true, $merge=false)
 
static setArray (&$destination, $source, $strict=false)
 

Detailed Description

Data Class.

Class to work with different data formats

Version
3.0
Author
Digger mrdig.nosp@m.ger@.nosp@m.sad-s.nosp@m.yste.nosp@m.ms.ru

Member Function Documentation

static load (   $fileName,
  $stripXmlAttributes = true 
)
static

Loads a data from file and returns data as a hash array.

The file can be in the following formats:

  • *.php
  • *.json
  • *.xml
Parameters
string | Array$fileNameThe name of config file. May be specified as a string or an array of strings (list of possible alternative file names).
For example: array("config.php", "config.json", "config.xml")
boolean$stripXmlAttributes
  • =TRUE, XML-tag's attributes will be ignored (except "value" attribute, its value will be saved as tag's value).
  • =FALSE, XML-tag's attributes will be stored as @attributes.
Returns
hash Array or FALSE, if file $fileName not found.
static set ( $destination,
  $source,
  $strict = false,
  $merge = false 
)
static

Set data from hash array (or config file) to a destination object or an array

Parameters
object$destinationLink to destination class or an array to be set.
string | hash$source"Config file name" or hash array of property values to set to destination.
boolean$strict=TRUE - non-existent properties will be ignored;
=FALSE - non-existent properties will be created and set.
boolean$merge=TRUE - if class property is an array new and old values will be merged (recursively).
Returns
boolean TRUE if properties of class was successfully set.
static setArray ( $destination,
  $source,
  $strict = false 
)
static

Copy data from source array to destination array

Parameters
array$destinationDestination array
array$sourceSource array
boolean$strictIf =TRUE the source key mast exists in desstination array or be a number
static setObject ( $destination,
  $source,
  $strict = true,
  $merge = false 
)
static

Copy data from source array to destination Object

Parameters
array$destinationDestination array
array$sourceSource array
boolean$strict=TRUE - non-existent properties will be ignored;
=FALSE - non-existent properties will be created and set.
boolean$merge=TRUE - if class property is an array new and old values will be merged (recursively)

The documentation for this class was generated from the following file: