TarzanUtilities

Utilities for connecting to, and working with, AWS.

Version

2008.12.18

Copyright

2006-2009 LifeNexus Digital, Inc., and contributors.

License

Simplified BSD Licensehttp://opensource.org/licenses/bsd-license.php

See Also

Tarzanhttp://tarzan-aws.com

TarzanUtilities

Container for all utility-related methods.

Functions

__construct()

public function __construct()

The constructor

Access

public

Returns

TarzanUtilities object

ready()

public function ready($var)

Check if a value (such as a GET or POST parameter or an array value) has a real, non-empty value.

Access

public

Parameters

vararray (Required) The value to check.

Returns

boolean Whether this has a real value.

See Also

Example Usagehttp://tarzan-aws.com/docs/examples/utilities/ready.phps

hex_to_base64()

public function hex_to_base64($str)

Convert a HEX value to Base64.

Access

public

Parameters

strstring (Required) Value to convert.

Returns

string Base64-encoded string.

See Also

Example Usagehttp://tarzan-aws.com/docs/examples/utilities/hex_to_base64.phps

to_query_string()

public function to_query_string($array)

Convert an associative array into a query string.

Access

public

Parameters

arrayarray (Required) Array to convert.

Returns

string URL-friendly query string.

See Also

Example Usagehttp://tarzan-aws.com/docs/examples/utilities/to_query_string.phps

to_signable_string()

public function to_signable_string($array)

Convert an associative array into a sign-able string.

Access

public

Parameters

arrayarray (Required) Array to convert.

Returns

string URL-friendly sign-able string.

See Also

Example Usagehttp://tarzan-aws.com/docs/examples/utilities/to_signable_string.phps

encode_signature2()

public function encode_signature2($string)

Encode the value according to RFC 3986.

Access

public

Parameters

stringstring (Required) String to convert

Returns

string URL-friendly sign-able string.

query_to_array()

public function query_to_array($qs)

Convert a query string into an associative array.  Multiple, identical keys will become an indexed array.

Access

public

Parameters

qsstring (Required) Query string to convert.

Returns

array Associative array of keys and values.

See Also

Example Usagehttp://tarzan-aws.com/docs/examples/utilities/query_to_array.phps

size_readable()

public function size_readable($size,  
$unit =  null,
$retstring =  null)

Return human readable file sizes.  Original function by Aidan Lister ai.nosp@m.dan@php.nosp@m..net, modified by Ryan Parman.

Access

public

Parameters

sizeinteger (Required) Filesize in bytes.
unitstring (Optional) The maximum unit to use.  Defaults to the largest appropriate unit.
retstringstring (Optional) The format for the return string.  Defaults to ‘%01.2f %s’

Returns

string The human-readable file size.

See Also

Original Functionhttp://aidanlister.com/repos/v/function.size_readable.php
Example Usagehttp://tarzan-aws.com/docs/examples/utilities/size_readable.phps

time_hms()

public function time_hms($seconds)

Convert a number of seconds into Hours:Minutes:Seconds.

Access

public

Parameters

secondsinteger (Required) The number of seconds to convert.

Returns

string The formatted time.

See Also

Example Usagehttp://tarzan-aws.com/docs/examples/utilities/time_hms.phps

try_these()

public function try_these($attrs,  
$base =  null,
$default =  null)

Returns the first value that is set.  Based on Try.these() from Prototype http://prototypejs.org.

Access

public

Parameters

attrsarray (Required) The attributes to test, as strings.  Intended for testing properties of the $base object, but also works with variables if you place an @ symbol at the beginning of the command.
baseobject (Optional) The base object to use, if any.
defaultmixed (Optional) What to return if there are no matches.  Defaults to null.

Returns

mixed Either a matching property of a given object, boolean false, or any other data type you might choose.

See Also

Example Usagehttp://tarzan-aws.com/docs/examples/utilities/try_these.phps

json_encode()

public function json_encode($obj)

Replicates json_encode() for versions of PHP 5 earlier than 5.2.

Author

http://us2.php.net/manual/en/function.json-encode.php#82904

Access

public

Parameters

objmixed (Required) The PHP object to convert into a JSON string.

Returns

string A JSON string.

See Also

Example Usagehttp://tarzan-aws.com/docs/examples/utilities/json_encode.phps