OpenCloud/Common/Base.php

Properties

Description

The root class for all other classes in this library

Classes

Base

Properties

 
 
 
Yes 
No 

Description

The Base class is the root class for all other objects used or defined by this SDK.
It contains common code for error handling as well as service functions that are useful. Because it is an abstract class, it cannot be called directly, and it has no publicly-visible properties.

Methods

CheckAttributePrefix, CheckJsonError, GetHttpRequestObject, MakeQueryString, SetProperty, Url, __set, debug, getDebug, getDebugOutputStyle, setDebug, setDebugOutputStyle, to_string,

CheckAttributePrefix( string   $property, array   $prefixes = array(), ) : boolean

Description

Checks the attribute $property and only permits it if the prefix is in the specified $prefixes array
This is to support extension namespaces in some services.

Arguments

Name Type Description Default
$property string

the name of the attribute

$prefixes array

a list of prefixes

array()

Return value

Type Description
boolean TRUE if valid; FALSE if not

CheckJsonError( ) : boolean

Description

Checks the most recent JSON operation for errors
This function should be called after any `json_*()` function call. This ensures that nasty JSON errors are detected and the proper exception thrown. Example: `$obj = json_decode($string);` `if (check_json_error()) do something ...`

Return value

Type Description
boolean TRUE if an error occurred, FALSE if none

Tags

Name Description
throws

GetHttpRequestObject(   $url,   $method = 'GET',   $options = array(), ) : n/a

Description

Returns a class that implements the HttpRequest interface.
This can be stubbed out for unit testing and avoid making live calls.

Arguments

Name Type Description Default
$url n/a
$method n/a 'GET'
$options n/a array()

Return value

Type Description
n/a n/a

MakeQueryString(   $array, ) : string

Description

Converts an array of key/value pairs into a single query string
For example, array('A'=>1,'B'=>2) would become 'A=1&B=2'.

Arguments

Name Type Description Default
$array n/a

Return value

Type Description
string

SetProperty( string   $property, mixed   $value, array   $prefixes = array(), ) : n/a

Description

Sets an extended (unrecognized) property on the current object
If RAXSDK_STRICT_PROPERTY_CHECKS is TRUE, then the prefix of the property name must appear in the $prefixes array, or else an exception is thrown.

Arguments

Name Type Description Default
$property string

the property name

$value mixed

the value of the property

$prefixes array

optional list of supported prefixes

array()

Return value

Type Description
n/a n/a

Tags

Name Description
throws if strict checks are on and the property prefix is not in the list of prefixes.

Url(   $subresource = '', ) : n/a

Description

Returns the URL of the service/object
The assumption is that nearly all objects will have a URL; at this base level, it simply throws an exception to enforce the idea that subclasses need to define this method.

Arguments

Name Type Description Default
$subresource n/a ''

Return value

Type Description
n/a n/a

Tags

Name Description
throws

__set( string   $property, mixed   $value, ) : void

Description

Sets extended attributes on an object and validates them
This function is provided to ensure that attributes cannot arbitrarily added to an object. If this function is called, it means that the attribute is not defined on the object, and thus an exception is thrown.

Arguments

Name Type Description Default
$property string

the name of the attribute

$value mixed

the value of the attribute

Return value

Type Description
void

debug( ) : void

Description

Displays a debug message if $RAXSDK_DEBUG is TRUE
The primary parameter is a string in sprintf() format, and it can accept up to five optional parameters. It prints the debug message, prefixed with "Debug:" and the class name, to the standard output device. Example: `$this->debug('Starting execution of %s', get_class($this))`

Return value

Type Description
void

Tags

Name Description
TODO - change this method name to something more descriptive/accurate

getDebug( ) : void

Description

getDebug function.

Return value

Type Description
void

Tags

Name Description
access public

getDebugOutputStyle( ) : void

Description

Gets the debug output style.

Return value

Type Description
void

Tags

Name Description
access public

setDebug(   $status, ) : void

Description

setDebug function.

Arguments

Name Type Description Default
$status n/a

Return value

Type Description
void

Tags

Name Description
access public

setDebugOutputStyle( mixed   $state, ) : void

Description

Sets the debug output style.

Arguments

Name Type Description Default
$state mixed

Return value

Type Description
void

Tags

Name Description
access public

to_string( mixed   $x, ) : string

Description

Converts a value to an HTTP-displayable string form

Arguments

Name Type Description Default
$x mixed

a value to convert

Return value

Type Description
string

Properties

$_errors, $debugOutputStyle, $debugStatus, $http_headers,

  private  $_errors = array()




bool  private  $debugOutputStyle = true

Sets the style for outputting debug messages.
Echoing messages == true Returning messages == false (default value: true)

bool  private  $debugStatus = false

Debug status.


  private  $http_headers = array()




Documentation was generated by phpDocumentor 2.0.0b6 .

Namespaces

Packages