File modules/template_engine/element/XMLFormatter.class.php

Last commit: Sun Feb 23 04:55:35 2020 +0100	Jan Dankert	New: Formatter for indenting XML files.
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 }
Download modules/template_engine/element/XMLFormatter.class.php
History Sun, 23 Feb 2020 04:55:35 +0100 Jan Dankert New: Formatter for indenting XML files.