filePath = $filePath ? $filePath : BASE_PATH . '/testSessionStubCode.php'; } /** * Writes arbitrary PHP code to {@link $filePath} for later inclusion. * Creates the file if it doesn't exist. * Adds debug information about the origin of this code if {@link $debug} is set. * * @param String $php Block of PHP code (without preceding debug ? debug_backtrace() : null; $path = $this->getFilePath(); $header = ''; // Create file incl. header if it doesn't exist if (!file_exists($this->getFilePath())) { touch($this->getFilePath()); if ($this->debug) { $header .= "debug) { $header .= "// Added by " . $trace[1]['class'] . '::' . $trace[1]['function'] . "\n"; } file_put_contents($path, $header . $php . "\n", FILE_APPEND); } public function reset() { if (file_exists($this->getFilePath())) { unlink($this->getFilePath()); } } public function getFilePath() { return $this->filePath; } public function getDebug() { return $this->debug; } public function setDebug($debug) { $this->debug = $debug; return $this; } }