Indention::__toString()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

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