class Utils

Class containing static utility functions

Methods

static string
camelise(string $str)

Convert a string into CamelCase

static bool
isAssociativeArray(mixed $param)

Check if something is an associative array

static string
removeFragmentFromUri(mixed $uri)

Remove the fragment from a URI (if it has one)

static string
dumpResourceValue(mixed $resource, string $format = 'html', string $color = 'blue')

Return pretty-print view of a resource URI

static string
dumpLiteralValue(mixed $literal, string $format = 'html', string $color = 'black')

Return pretty-print view of a literal

static array
parseMimeType(string $mimeType)

Clean up and split a mime-type up into its parts

static string
execCommandPipe(string $command, array $args = null, string $input = null, string $dir = null)

Execute a command as a pipe

Details

at line 63
static string camelise(string $str)

Convert a string into CamelCase

A capital letter is inserted for any non-letter (including userscore). For example: 'hello world' becomes HelloWorld 'rss-tag-soup' becomes RssTagSoup 'FOO//BAR' becomes FooBar

Parameters

string $str The input string

Return Value

string The input string converted to CamelCase

at line 81
static bool isAssociativeArray(mixed $param)

Check if something is an associative array

Note: this method only checks the key of the first value in the array.

Parameters

mixed $param The variable to check

Return Value

bool true if the variable is an associative array

at line 102
static string removeFragmentFromUri(mixed $uri)

Remove the fragment from a URI (if it has one)

Parameters

mixed $uri A URI

Return Value

string The same URI with the fragment removed

at line 125
static string dumpResourceValue(mixed $resource, string $format = 'html', string $color = 'blue')

Return pretty-print view of a resource URI

This method is mainly intended for internal use and is used by EasyRdf\Graph and EasyRdf\Sparql\Result to format a resource for display.

Parameters

mixed $resource An EasyRdf\Resource object or an associative array
string $format Either 'html' or 'text'
string $color The colour of the text

Return Value

string

Exceptions

InvalidArgumentException

at line 174
static string dumpLiteralValue(mixed $literal, string $format = 'html', string $color = 'black')

Return pretty-print view of a literal

This method is mainly intended for internal use and is used by EasyRdf\Graph and EasyRdf\Sparql\Result to format a literal for display.

Parameters

mixed $literal An EasyRdf\Literal object or an associative array
string $format Either 'html' or 'text'
string $color The colour of the text

Return Value

string

Exceptions

InvalidArgumentException

at line 216
static array parseMimeType(string $mimeType)

Clean up and split a mime-type up into its parts

Parameters

string $mimeType A MIME Type, optionally with parameters

Return Value

array $type, $parameters

at line 244
static string execCommandPipe(string $command, array $args = null, string $input = null, string $dir = null)

Execute a command as a pipe

The proc_open() function is used to open a pipe to a a command line process, writing $input to STDIN, returning STDOUT and throwing an exception if anything is written to STDERR or the process returns non-zero.

Parameters

string $command The command to execute
array $args Optional list of arguments to pass to the command
string $input Optional buffer to send to the command
string $dir Path to directory to run command in (defaults to /tmp)

Return Value

string The result of the command, printed to STDOUT

Exceptions

Exception