testphase
  • Namespace
  • Class
  • Tree
  • Deprecated
  • Todo

Namespaces

  • Phramework
    • Exceptions
    • Testphase
      • Exceptions
    • Validate

Classes

  • Binary
  • Expression
  • Globals
  • Server
  • TestParser
  • Testphase
  • Util

Class Globals

Global variables

Namespace: Phramework\Testphase
License: Apache-2.0
Author: Xenofon Spafaridis nohponex@gmail.com
Version: 1.0.0
Since: 1.0.0
Located at Globals.php

Methods summary

protected static
# initializeGlobals( )

Todo

keep a documentation record of globals
public static boolean
# exists( string $key )

Check if global variable exists

Check if global variable exists

Parameters

$key

Returns

boolean

Throws

Exception
public static mixed|callable|array
# get( string $key = null, $operators = null )

Get global key's value. An expression to access array elements or a function can be given.

Get global key's value. An expression to access array elements or a function can be given.

Parameters

$key
Expression key, can have parenthesis or square brackets operator.
$operators

Returns

mixed|callable|array

If you access a function without the parenthesis operator or an array without square brackets operator then this method will return the callable or the whole array respectively.

Throws

Exception
When expression key is invalid.
Phramework\Exceptions\NotFoundException
When key is not found.

Example

Globals::get('myVarible');

Globals::get('rand-boolean()');

Globals::get('rand-integer(10)'); //A random integer from 0 to 10

Globals::get('myArray[1]'); //Get second array element

public static mixed[]
# handleFunctionVariable( string[] $parameters )

Parameters

$parameters

Returns

mixed[]
public static mixed
# handleArrayVariable( string $value )

Parameters

$value

Returns

mixed

Throws

Phramework\Testphase\Exceptions\UnsetGlobalException
Exception
public static
# set( string $key, mixed $value )

Will overwrite value with same key

Will overwrite value with same key

Parameters

$key
Key
$value

Throws

Exception
When key is invalid, see Expression::PATTERN_KEY

Example

Globals::set('myVariable', 5);
Globals::set(
    'dots',
    function ($length = 4) {
        return str_repeat('.', $length);
    }
);

Globals::get('dots()'); //Will return a string of 4 dots
Globals::get('dots(10)'); //Will return a string of 10 dots

public static string
# toString( )

Return keys and values of global variables as string

Return keys and values of global variables as string

Returns

string

Constants summary

string KEY_VARIABLE

Key of type variable

Key of type variable

# 'variable'
string KEY_FUNCTION

Key of type function

Key of type function

# 'function'
string KEY_ARRAY

Key of type array

Key of type array

# 'array'

Properties summary

protected static object $globals
# null
testphase API documentation generated by ApiGen