Back to index

php5  5.3.10
gtCodeSnippet.php
Go to the documentation of this file.
00001 <?php
00002 
00007 class gtCodeSnippet
00008 {
00009 
00016   public static function get($name) {
00017     
00018     $filename = dirname(__FILE__) . '/codeSnippets/' . $name . '.txt';
00019 
00020     if (!file_exists($filename)) {
00021       throw new LogicException('The code snippet ' . $name . ' does not exist');
00022     }
00023     
00024     $lines = file($filename);
00025     foreach($lines as $l) {
00026       $array[] = rtrim($l);
00027     }
00028     return $array;
00029   }
00030   
00031   
00039   public static function append($name, $array) {
00040     $filename = dirname(__FILE__) . '/codeSnippets/' . $name . '.txt';
00041 
00042     if (!file_exists($filename)) {
00043       throw new LogicException('The code snippet ' . $name . ' does not exist');
00044     }
00045 
00046     $text =  file($filename);
00047     foreach ($text as $t) {
00048       $array[] = rtrim($t);
00049     }
00050     
00051     return $array;
00052   }
00053   
00054   
00062   public static function appendBlankLines($numberOfLines, $array) {
00063 
00064     for ($i=0; $i< $numberOfLines; $i++) {
00065       $array[] = "";
00066     }
00067     
00068     return $array;
00069   }
00070   
00071 }
00072 ?>