Core  3.2
PHP API documentation
 All Data Structures Namespaces Files Functions Variables Pages
ApiUsage Class Reference

Verify arguments for wsh programs. More...

+ Inheritance diagram for ApiUsage:
+ Collaboration diagram for ApiUsage:

Public Member Functions

 __construct ()
 
 setText ($text)
 
 setDefinitionText ($text)
 
 addHidden ($argName, $argDefinition)
 
 addHiddenParameter ($argName, $argDefinition)
 
 addNeeded ($argName, $argDefinition, array $restriction=null)
 
 addRequiredParameter ($argName, $argDefinition, $restriction=null)
 
 addOption ($argName, $argDefinition, array $restriction=null, $default=null)
 
 addOptionalParameter ($argName, $argDefinition, $restriction=null, $default=null)
 
 addEmpty ($argName, $argDefinition="")
 
 addEmptyParameter ($argName, $argDefinition="")
 
 getUsage ()
 
 exitError ($error= '')
 
 strict ($strict=true)
 if false additionnal arguments are ignored, default is true More...
 
 setStrictMode ($strict=true)
 if false additionnal arguments are ignored, default is true More...
 
 verify ($useException=false)
 

Static Public Member Functions

static isScalar ($argVal, $argName, $apiUsage)
 
static isArray ($argVal, $argName, $apiUsage)
 
static matchValues ($value, $restrictions)
 

Data Fields

const THROW_EXITHELP = 1988
 
const GET_USAGE = null
 

Protected Member Functions

 getArgumentValue ($key, $defaultValue= '')
 
 isCallable ($f)
 
 getHiddenKeys ()
 

Protected Attributes

 $action
 
 $strict = true
 
 $useException = false
 

Detailed Description

Verify arguments for wsh programs.

Verify arguments for wsh programs

$usage = new ApiUsage();
$usage->setDescriptionText("Refresh documents ");
$usage->addRequiredParameter("famid", "the family filter");
$usage->addOptionalParameter("revision", "use all revision - default is no", array(
"yes",
"no"
));
$usage->addOptionalParameter("save", "use modify default is light", array(
"complete",
"light",
"none"
));
$usage->verify();

Definition at line 28 of file Class.ApiUsage.php.

Constructor & Destructor Documentation

__construct ( )

init action

Definition at line 83 of file Class.ApiUsage.php.

+ Here is the call graph for this function:

Member Function Documentation

addEmpty (   $argName,
  $argDefinition = "" 
)

add empty argument (argument with boolean value)

See Also
ApiUsage::addEmptyParameter
Deprecated:
use ApiUsage::addEmptyParameter instead
Parameters
string$argNameargument name
string$argDefinitionargument definition
Returns
string argument value

Definition at line 276 of file Class.ApiUsage.php.

+ Here is the call graph for this function:

addEmptyParameter (   $argName,
  $argDefinition = "" 
)

add empty argument (argument with boolean value)

Api:
add empty argument (argument with boolean value)
Parameters
string$argNameargument name
string$argDefinitionargument definition
Returns
string argument value

Definition at line 291 of file Class.ApiUsage.php.

+ Here is the call graph for this function:

addHidden (   $argName,
  $argDefinition 
)

add hidden argument (private arg not see them in usage)

See Also
ApiUsage::addHiddenParameter
Deprecated:
use ApiUsage::addHiddenParameter instead
Parameters
string$argNameargument name
string$argDefinitionargument définition
Returns
string argument value

Definition at line 162 of file Class.ApiUsage.php.

+ Here is the call graph for this function:

addHiddenParameter (   $argName,
  $argDefinition 
)

add hidden argument (private arg not see them in usage)

Api:
add an empty parameter
Parameters
string$argNameargument name
string$argDefinitionargument définition
Returns
string argument value

Definition at line 177 of file Class.ApiUsage.php.

+ Here is the call graph for this function:

addNeeded (   $argName,
  $argDefinition,
array  $restriction = null 
)

add needed argument

See Also
ApiUsage::addRequiredParameter
Deprecated:
use ApiUsage::addRequiredParameter instead
Parameters
string$argNameargument name
string$argDefinitionargument définition
array$restrictionoptional enumeration for argument
Returns
string argument value

Definition at line 198 of file Class.ApiUsage.php.

+ Here is the call graph for this function:

addOption (   $argName,
  $argDefinition,
array  $restriction = null,
  $default = null 
)

add optional argument

See Also
ApiUsage::addOptionParameter
Deprecated:
use ApiUsage::addOptionParameter instead
Parameters
string$argNameargument name
string$argDefinitionargument définition
array$restrictionoptional enumeration for argument
string$defaultdefault value if no value set
Returns
string argument value

Definition at line 237 of file Class.ApiUsage.php.

+ Here is the call graph for this function:

addOptionalParameter (   $argName,
  $argDefinition,
  $restriction = null,
  $default = null 
)

add optional argument

Api:
add optional argument
Parameters
string$argNameargument name
string$argDefinitionargument definition
array | callable$restrictionoptional enumeration for argument
string$defaultdefault value if no value set
Returns
string argument value

Definition at line 254 of file Class.ApiUsage.php.

+ Here is the call graph for this function:

addRequiredParameter (   $argName,
  $argDefinition,
  $restriction = null 
)

add needed argument

Api:
add needed argument
Parameters
string$argNameargument name
string$argDefinitionargument définition
array | callable$restrictionoptional enumeration for argument
Returns
string argument value

Definition at line 214 of file Class.ApiUsage.php.

+ Here is the call graph for this function:

exitError (   $error = '')

exit when error

Parameters
string$errormessage error
Exceptions
Dcp\ApiUsage\Exception
Returns
void

Definition at line 383 of file Class.ApiUsage.php.

+ Here is the call graph for this function:

getArgumentValue (   $key,
  $defaultValue = '' 
)
protected

Return value of argument key

Parameters
string$keythe identifier
string$defaultValuevalue to return if value is empty
Returns
mixed|string

Definition at line 307 of file Class.ApiUsage.php.

getHiddenKeys ( )
protected

list hidden keys

Returns
array

Definition at line 414 of file Class.ApiUsage.php.

getUsage ( )

return usage text for the action

Returns
string

Definition at line 366 of file Class.ApiUsage.php.

static isArray (   $argVal,
  $argName,
  $apiUsage 
)
static

Restriction callback to verify an array value

Parameters
string$argValargument value
string$argNameargument name
ApiUsage$apiUsagecurrent apiUsage object
Returns
string

Definition at line 117 of file Class.ApiUsage.php.

isCallable (   $f)
protected

Definition at line 341 of file Class.ApiUsage.php.

static isScalar (   $argVal,
  $argName,
  $apiUsage 
)
static

Restriction callback to verify a scalar value

Parameters
string$argValargument value
string$argNameargument name
ApiUsage$apiUsagecurrent apiUsage object
Returns
string

Definition at line 98 of file Class.ApiUsage.php.

static matchValues (   $value,
  $restrictions 
)
static
Parameters
$value
$restrictions
Returns
string

Definition at line 510 of file Class.ApiUsage.php.

setDefinitionText (   $text)

add textual definition of program

Api:
add textual definition of program
Parameters
string$textusage text
Returns
void

Definition at line 146 of file Class.ApiUsage.php.

setStrictMode (   $strict = true)

if false additionnal arguments are ignored, default is true

set strict mode

Api:
set strict mode
Parameters
boolean$strictstrict mode
Returns
void

Definition at line 449 of file Class.ApiUsage.php.

+ Here is the call graph for this function:

setText (   $text)

add textual definition of program

See Also
setDefinitionText
Parameters
string$textusage text
Deprecated:
use ApiUsage::setDefinitionText instead
Returns
void setText

Definition at line 133 of file Class.ApiUsage.php.

+ Here is the call graph for this function:

strict (   $strict = true)

if false additionnal arguments are ignored, default is true

set strict mode

See Also
ApiUsage::setStrictMode
Deprecated:
use Application::setStrictMode instead
Parameters
boolean$strictstrict mode
Returns
void

Definition at line 434 of file Class.ApiUsage.php.

+ Here is the call graph for this function:

verify (   $useException = false)

verify if wsh program argument are valids. If not wsh exit

Api:
Verify if wsh's program arguments are valid
Parameters
bool$useExceptionif true throw ApiUsageException when verify is not successful
Returns
void

Definition at line 461 of file Class.ApiUsage.php.

+ Here is the call graph for this function:

Field Documentation

$action
protected

Definition at line 67 of file Class.ApiUsage.php.

$strict = true
protected

Definition at line 73 of file Class.ApiUsage.php.

$useException = false
protected

Definition at line 79 of file Class.ApiUsage.php.

const GET_USAGE = null

Definition at line 31 of file Class.ApiUsage.php.

const THROW_EXITHELP = 1988

Definition at line 30 of file Class.ApiUsage.php.


The documentation for this class was generated from the following file:
← centre documentaire © anakeen