3 namespace Org\Mxchange\CoreFramework\Output\Debug;
5 // Import framework stuff
6 use Org\Mxchange\CoreFramework\Debug\Debugger;
7 use Org\Mxchange\CoreFramework\Generic\FrameworkInterface;
8 use Org\Mxchange\CoreFramework\Generic\UnsupportedOperationException;
9 use Org\Mxchange\CoreFramework\Output\Debug\BaseDebugOutput;
10 use Org\Mxchange\CoreFramework\Stream\Output\OutputStreamer;
13 * A debug output class for the web browser
15 * @author Roland Haeder <webmaster@shipsimu.org>
17 * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2022 Core Developer Team
18 * @license GNU GPL 3.0 or any newer version
19 * @link http://www.shipsimu.org
21 * This program is free software: you can redistribute it and/or modify
22 * it under the terms of the GNU General Public License as published by
23 * the Free Software Foundation, either version 3 of the License, or
24 * (at your option) any later version.
26 * This program is distributed in the hope that it will be useful,
27 * but WITHOUT ANY WARRANTY; without even the implied warranty of
28 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
29 * GNU General Public License for more details.
31 * You should have received a copy of the GNU General Public License
32 * along with this program. If not, see <http://www.gnu.org/licenses/>.
34 class DebugWebOutput extends BaseDebugOutput implements Debugger, OutputStreamer {
36 * Protected constructor
40 private function __construct () {
41 // Call parent constructor
42 parent::__construct(__CLASS__);
46 * Creates an instance of this class
48 * @return $debugInstance The prepared debug instance
50 public static final function createDebugWebOutput () {
52 $debugInstance = new DebugWebOutput();
55 return $debugInstance;
59 * Outputs the given data directly, ignores $stripTags
61 * @param $output The HTML output
62 * @param $stripTags Whether HTML tags shall be stripped out
65 public final function outputStream (string $output, bool $stripTags = false) {
66 // Strip out any <br />
67 $output = str_replace('<br />', '', $output);
68 printf('<!-- %s -->' . PHP_EOL, stripslashes($output));
74 * @param $outStream Stream to output
75 * @param $stripTags Whether HTML tags shall be stripped out
78 public final function output (string $outStream = '', bool $stripTags = false) {
79 // Empty output will be silently ignored
80 if (!empty($outStream)) {
81 $this->outputStream($outStream, $stripTags);
86 * Streams the data and maybe does something to it
88 * @param $data The data (string mostly) to "stream"
89 * @return $data The data (string mostly) to "stream"
90 * @throws UnsupportedOperationException If this method is called
92 public function streamData (string $data) {
93 self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('Unhandled ' . strlen($data) . ' bytes in this stream.');
94 throw new UnsupportedOperationException([$this, __FUNCTION__], FrameworkInterface::EXCEPTION_UNSPPORTED_OPERATION);