Class Graphite_Graph_CallSpec

Description of the call specification for a Graphite function.

Author(s):
Copyright:   2012 Bryan Davis and contributors. All Rights Reserved.
License:   Simplified BSD License

Constants

FMT_FORMAT_ARG Sprintf format string for creating a lambda function to format a list of arguments.

Member Variables

protected bool $isAlias
Does this function provide an alias for the series?
protected string $name
Canonical name of the function.
protected int $order
Sort order.
protected array $signature
Description of function arguments.
protected bool $usesSeries
Does this function wrap a series?

Method Summary

public static bool argHasMods( $arg )
Does the given argument have modifiers?
public static bool argIsOptional( $arg )
Is the given argument optional?
public static bool argIsString( $arg )
Is the given argument optional?
public static bool argIsWildcard( $arg )
Is the given argument a wildcard?
public static int cmp( $a , $b )
Compare two CallSpecs for sort ordering.
public static mixed format( $arg , $type )
Format an argument as a specified type.
public string asString( $series , $args )
Format the call for use as a target.
public Graphite_Graph_CallSpec __construct( $name , $signature , [ $order = 50] , [ $alias = false] , [ $generator = false] )
Constructor.
public string getArg( $idx )
Get the Nth argument spec.
public bool isAlias( )
Does this function provide an alias for the series?
public int maxArgs( )
How many args are possible for this function?
public int requiredArgs( )
How many args are required for this function?
public bool takesArgs( )
Does this function require arguments other than a series?

Methods

argHasMods

static bool argHasMods( string $arg )

Does the given argument have modifiers?

Parameters:

Name Type Description
$arg string Argument description to check

argIsOptional

static bool argIsOptional( string $arg )

Is the given argument optional?

Parameters:

Name Type Description
$arg string Argument description to check

argIsString

static bool argIsString( string $arg )

Is the given argument optional?

Parameters:

Name Type Description
$arg string Argument description to check

argIsWildcard

static bool argIsWildcard( string $arg )

Is the given argument a wildcard?

Parameters:

Name Type Description
$arg string Argument description to check

cmp

static int cmp( CallSpec $a , CallSpec $b )

Compare two CallSpecs for sort ordering.

Parameters:

Name Type Description
$a CallSpec First spec
$b CallSpec Second spec

format

static mixed format( mixed $arg , string $type )

Format an argument as a specified type.

$type is one of:

  • - : Verbatum
  • " : Quoted String
  • # : Numeric
  • ^ : Boolean
  • ! : Flag parameter (null to omit from call, non-null to include)

Parameters:

Name Type Description
$arg mixed Argument to format
$type string Output type

asString

string asString( string $series , array $args )

Format the call for use as a target.

Arguments to the function can be provided as an array or using a varadic argument style.

  1.  // args provided as array
  2.  $out $callSpec->asString('*'array(123));
  3.  
  4.  // varadic args
  5.  $out $callSpec->asString('*'123);

If this call is a generator the $series argument will be ignored.

Parameters:

Name Type Description
$series string Series to apply function to
$args array Arguments to function

__construct

Graphite_Graph_CallSpec __construct( string $name , mixed $signature , [int $order = 50] , [bool $alias = false] , [bool $generator = false] )

Constructor.

  • $signature is a single value or array of argument specs.
  • $order is an integer between 1 and 99 used to sort functions when nesting.
  • $alias is truthy if this function provides a legend alias.
An argument spec is a string specifying the output type of the argument and an optional modifier.

Output type is one of:

  • - : Verbatum
  • " : Quoted String
  • # : Numeric
  • ^ : Boolean
  • ! : Flag parameter (null to omit from call, non-null to include)
Modifier is one of:
  • - : Verbatum (default if omitted)
  • ? : Argument is optional
  • * : Variadic args
  • < : Argument preceeds series in call

Parameters:

Name Type Description
$name string Function name
$signature mixed Argument spec
$order int Sort order
$alias bool Does this function provide an alias?
$generator bool Is this function a generator?

getArg

string getArg( int $idx )

Get the Nth argument spec.

Parameters:

Name Type Description
$idx int Argument index

isAlias

bool isAlias( )

Does this function provide an alias for the series?

maxArgs

int maxArgs( )

How many args are possible for this function?

requiredArgs

int requiredArgs( )

How many args are required for this function?

takesArgs

bool takesArgs( )

Does this function require arguments other than a series?

Located in /src/Graphite/Graph/CallSpec.php [line 19]