Completed
Push — master ( d71f5d...704662 )
by Fabio
21:55
created

TTextHighlighterWriter::write()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 10
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 2
eloc 6
nc 2
nop 1
dl 0
loc 10
rs 9.4285
c 0
b 0
f 0
1
<?php
2
/**
3
 * TTextHighlighterWriter class file
4
 *
5
 * @author Fabio Bas <ctrlaltca[at]gmail[dot]com>
6
 * @link https://github.com/pradosoft/prado
7
 * @copyright Copyright &copy; 2005-2016 The PRADO Group
8
 * @license https://github.com/pradosoft/prado/blob/master/LICENSE
9
 * @package Prado\Web\UI\WebControls
10
 */
11
12
/**
13
 * TTextHighlighterWriter class.
14
 *
15
 * TTextHighlighterWriter is an helper class for {@link TTextHighlighter} that provides html encoding and
16
 * avoids a blank line from being printed at the beginning of the code.
17
 *
18
 * @author Fabio Bas <ctrlaltca[at]gmail[dot]com>
19
 * @package Prado\Web\UI\WebControls
20
 * @since 4.0
21
 */
22
23
namespace Prado\Web\UI\WebControls;
24
use Prado\Prado;
25
use Prado\Web\THttpUtility;
26
27
class TTextHighlighterWriter extends \Prado\Web\UI\THtmlWriter
28
{
29
	protected $firstLine = true;
30
	/**
31
	 * Renders a string.
32
	 * @param string string to be rendered
33
	 */
34
	public function write($str)
35
	{
36
		if($this->firstLine)
37
		{
38
			$this->firstLine=false;
39
			$this->_writer->write(THttpUtility::htmlEncode(ltrim($str)));
40
		} else {
41
			$this->_writer->write(THttpUtility::htmlEncode($str));
42
		}
43
	}
44
}
45