openrat-cms

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs | README

XMLFormatter.class.php (657B)


      1 <?php
      2 
      3 
      4 namespace template_engine\element;
      5 
      6 
      7 class XMLFormatter
      8 {
      9 	private $depth;
     10 	private $indent;
     11 
     12 	/**
     13 	 * XMLFormatter constructor.
     14 	 * @param $indent
     15 	 */
     16 	public function __construct($indent)
     17 	{
     18 		$this->depth = 0;
     19 		$this->indent = $indent;
     20 	}
     21 
     22 
     23 	public function deeper() {
     24 		$deeper = clone $this;
     25 		$deeper->depth+=1;
     26 		return $deeper;
     27 	}
     28 
     29 	public function getIndentation() {
     30 		if   ( $this->depth && $this->indent )
     31 			return "\n".str_repeat($this->indent,$this->depth );
     32 		else
     33 			return '';
     34 	}
     35 
     36 	public function getIndentationOnClose() {
     37 		if   ( $this->indent )
     38 			return "\n".str_repeat($this->indent,$this->depth );
     39 		else
     40 			return '';
     41 	}
     42 }