1: 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21: 22: 23: 24: 25: 26: 27: 28: 29: 30: 31: 32: 33: 34: 35: 36: 37: 38: 39: 40: 41: 42: 43: 44: 45: 46: 47: 48: 49: 50: 51: 52: 53: 54: 55: 56: 57: 58: 59: 60: 61: 62: 63: 64: 65: 66: 67: 68: 69: 70: 71: 72: 73: 74: 75: 76: 77: 78: 79: 80: 81: 82: 83: 84: 85: 86: 87: 88: 89: 90: 91: 92: 93:
<?php
/**
* @author stev leibelt <artodeto@bazzline.net>
* @since 2014-05-02
*/
namespace Net\Bazzline\Component\CodeGenerator;
/**
* Class Indention
* @package Net\Bazzline\Component\CodeGenerator
*/
class Indention
{
const FOUR_SPACES_INDENTION = ' ';
const TAB_INDENTION = "\t";
const INITIAL_LEVEL = 0;
/**
* @var int
*/
private $level = self::INITIAL_LEVEL;
/**
* @var string
*/
private $string = self::FOUR_SPACES_INDENTION;
/**
* @return string
*/
public function getString()
{
return $this->string;
}
/**
* @param string $indention
* @return $this
*/
public function setString($indention)
{
$this->string = (string) $indention;
return $this;
}
/**
* @param int $number
* @return $this
*/
public function decreaseLevel($number = 1)
{
$this->level = (($this->level - $number) < self::INITIAL_LEVEL) ? self::INITIAL_LEVEL : ($this->level - $number);
return $this;
}
/**
* @param int $number
* @return $this
*/
public function increaseLevel($number = 1)
{
$this->level += $number;
return $this;
}
/**
* @return int
*/
public function isSetToInitialLevel()
{
return ($this->level === self::INITIAL_LEVEL);
}
/**
* @return string
*/
public function toString()
{
return (str_repeat($this->string, $this->level));
}
/**
* @return string
*/
public function __toString()
{
return $this->toString();
}
}