<?php
class gtCodeSnippet
{
public static function get($name) {
$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;
}
public static function append($name, $array) {
$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;
}
public static function appendBlankLines($numberOfLines, $array) {
for ($i=0; $i< $numberOfLines; $i++) {
$array[] = "";
}
return $array;
}
}
?>