summaryrefslogtreecommitdiff
path: root/scripts/dev/generate-phpt/src/gtCodeSnippet.php
diff options
context:
space:
mode:
authorSean Finney <seanius@debian.org>2009-06-24 22:49:04 +0200
committerSean Finney <seanius@debian.org>2009-06-24 22:49:04 +0200
commit84f4ca9b07fe5b73d840258f4aa7c1eb534c4253 (patch)
tree9829bd578af8a4a8b42b04277f9067e00dc5ad90 /scripts/dev/generate-phpt/src/gtCodeSnippet.php
parent6821b67124604da690c5e9276d5370d679c63ac8 (diff)
downloadphp-84f4ca9b07fe5b73d840258f4aa7c1eb534c4253.tar.gz
Imported Upstream version 5.3.0~RC4upstream/5.3.0_RC4upstream/5.3.0.RC4
Diffstat (limited to 'scripts/dev/generate-phpt/src/gtCodeSnippet.php')
-rw-r--r--scripts/dev/generate-phpt/src/gtCodeSnippet.php72
1 files changed, 72 insertions, 0 deletions
diff --git a/scripts/dev/generate-phpt/src/gtCodeSnippet.php b/scripts/dev/generate-phpt/src/gtCodeSnippet.php
new file mode 100644
index 000000000..220fbdf69
--- /dev/null
+++ b/scripts/dev/generate-phpt/src/gtCodeSnippet.php
@@ -0,0 +1,72 @@
+<?php
+
+/**
+ * Retrieves code snippets for adding to test cases
+ *
+ */
+class gtCodeSnippet
+{
+
+ /**
+ * get the code snippet and initialise an array with it
+ *
+ * @param string $name
+ * @return array
+ */
+ 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;
+ }
+
+
+ /**
+ * Append the code snippet on to an existing array
+ *
+ * @param string $name
+ * @param array $array
+ * @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;
+ }
+
+
+ /**
+ * Appends blank entries on to an array
+ *
+ * @param int $numberOfLines
+ * @param array $array
+ * @return array
+ */
+ public static function appendBlankLines($numberOfLines, $array) {
+
+ for ($i=0; $i< $numberOfLines; $i++) {
+ $array[] = "";
+ }
+
+ return $array;
+ }
+
+}
+?> \ No newline at end of file