Back to index

php5  5.3.10
Static Public Member Functions
gtCodeSnippet Class Reference

Retrieves code snippets for adding to test cases. More...

List of all members.

Static Public Member Functions

static get ($name)
 get the code snippet and initialise an array with it
static append ($name, $array)
 Append the code snippet on to an existing array.
static appendBlankLines ($numberOfLines, $array)
 Appends blank entries on to an array.

Detailed Description

Retrieves code snippets for adding to test cases.

Definition at line 7 of file gtCodeSnippet.php.


Member Function Documentation

static gtCodeSnippet::append ( name,
array 
) [static]

Append the code snippet on to an existing array.

Parameters:
string$name
array$array
Returns:
array

Definition at line 39 of file gtCodeSnippet.php.

                                               {
    $filename = dirname(__FILE__) . '/codeSnippets/' . $name . '.txt';

    if (!file_exists($filename)) {
      throw new LogicException('The code snippet ' . $name . ' does not exist');
    }

    $text =  file($filename);
    foreach ($text as $t) {
      $array[] = rtrim($t);
    }
    
    return $array;
  }

Here is the caller graph for this function:

static gtCodeSnippet::appendBlankLines ( numberOfLines,
array 
) [static]

Appends blank entries on to an array.

Parameters:
int$numberOfLines
array$array
Returns:
array

Definition at line 62 of file gtCodeSnippet.php.

                                                                  {

    for ($i=0; $i< $numberOfLines; $i++) {
      $array[] = "";
    }
    
    return $array;
  }

Here is the caller graph for this function:

static gtCodeSnippet::get ( name) [static]

get the code snippet and initialise an array with it

Parameters:
string$name
Returns:
array

Definition at line 16 of file gtCodeSnippet.php.

                                    {
    
    $filename = dirname(__FILE__) . '/codeSnippets/' . $name . '.txt';

    if (!file_exists($filename)) {
      throw new LogicException('The code snippet ' . $name . ' does not exist');
    }
    
    $lines = file($filename);
    foreach($lines as $l) {
      $array[] = rtrim($l);
    }
    return $array;
  }

The documentation for this class was generated from the following file: