3 namespace Org\Mxchange\CoreFramework\Output\Debug;
5 // Import framework stuff
6 use Org\Mxchange\CoreFramework\Debug\Debugger;
7 use Org\Mxchange\CoreFramework\Generic\UnsupportedOperationException;
8 use Org\Mxchange\CoreFramework\Output\Debug\BaseDebugOutput;
9 use Org\Mxchange\CoreFramework\Stream\Output\OutputStreamer;
12 * A debug output class for the web browser
14 * @author Roland Haeder <webmaster@shipsimu.org>
16 * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2020 Core Developer Team
17 * @license GNU GPL 3.0 or any newer version
18 * @link http://www.shipsimu.org
20 * This program is free software: you can redistribute it and/or modify
21 * it under the terms of the GNU General Public License as published by
22 * the Free Software Foundation, either version 3 of the License, or
23 * (at your option) any later version.
25 * This program is distributed in the hope that it will be useful,
26 * but WITHOUT ANY WARRANTY; without even the implied warranty of
27 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
28 * GNU General Public License for more details.
30 * You should have received a copy of the GNU General Public License
31 * along with this program. If not, see <http://www.gnu.org/licenses/>.
33 class DebugWebOutput extends BaseDebugOutput implements Debugger, OutputStreamer {
35 * Protected constructor
39 protected function __construct () {
40 // Call parent constructor
41 parent::__construct(__CLASS__);
45 * Creates an instance of this class
47 * @return $debugInstance The prepared debug instance
49 public static final function createDebugWebOutput () {
51 $debugInstance = new DebugWebOutput();
54 return $debugInstance;
58 * Outputs the given data directly, ignores $stripTags
60 * @param $output The HTML output
61 * @param $stripTags Whether HTML tags shall be stripped out
64 public final function outputStream ($output, $stripTags = false) {
65 // Strip out any <br />
66 $output = str_replace('<br />', '', $output);
67 printf('<!-- %s -->' . PHP_EOL, stripslashes($output));
73 * @param $outStream Stream to output
74 * @param $stripTags Whether HTML tags shall be stripped out
77 public final function output ($outStream = false, $stripTags = false) {
78 // Empty output will be silently ignored
79 if ($outStream !== false) {
80 $this->outputStream($outStream, $stripTags);
85 * Streams the data and maybe does something to it
87 * @param $data The data (string mostly) to "stream"
88 * @return $data The data (string mostly) to "stream"
89 * @throws UnsupportedOperationException If this method is called
91 public function streamData ($data) {
92 self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('Unhandled ' . strlen($data) . ' bytes in this stream.');
93 throw new UnsupportedOperationException(array($this, __FUNCTION__), self::EXCEPTION_UNSPPORTED_OPERATION);
97 * Determines seek position
99 * @return $seekPosition Current seek position
100 * @throws UnsupportedOperationException If this method is called
102 public function determineSeekPosition () {
103 throw new UnsupportedOperationException(array($this, __FUNCTION__), self::EXCEPTION_UNSPPORTED_OPERATION);
107 * Seek to given offset (default) or other possibilities as fseek() gives.
109 * @param $offset Offset to seek to (or used as "base" for other seeks)
110 * @param $whence Added to offset (default: only use offset to seek to)
111 * @return $status Status of file seek: 0 = success, -1 = failed
112 * @throws UnsupportedOperationException If this method is called
114 public function seek ($offset, $whence = SEEK_SET) {
115 self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('[' . __METHOD__ . ':' . __LINE__ . '] offset=' . $offset . ',whence=' . $whence);
116 throw new UnsupportedOperationException(array($this, __FUNCTION__), self::EXCEPTION_UNSPPORTED_OPERATION);
122 * @return $size Size (in bytes) of file
123 * @throws UnsupportedOperationException If this method is called
125 public function size () {
126 throw new UnsupportedOperationException(array($this, __FUNCTION__), self::EXCEPTION_UNSPPORTED_OPERATION);