CodeWriter::getTimestamp()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 1
c 0
b 0
f 0
nc 1
nop 0
dl 0
loc 3
rs 10
1
<?php
2
namespace yentu;
3
4
class CodeWriter
5
{
6
    private $lines = "";
7
    private $indentation = 0;
8
    
9
    public function add($line = '')
10
    {
11
        $this->lines .= str_repeat(' ', $this->indentation) . "$line\n";
12
    }
13
    
14
    public function addNoLn($line = '')
15
    {
16
        $this->lines .= str_repeat(' ', $this->indentation) . "$line";
17
    }
18
    
19
    public function addNoIndent($line = '')
20
    {
21
        $this->lines .= $line;
22
    }
23
    
24
    public function ln()
25
    {
26
        $this->lines .= "\n";
27
    }
28
29
    
30
    public function addIndent()
31
    {
32
        $this->indentation += 4;
33
    }
34
    
35
    public function decreaseIndent()
36
    {
37
        $this->indentation -= 4;
38
    }
39
    
40
    public function __toString()
41
    {
42
        $timestamp = $this->getTimestamp();
43
        $header = <<< HEAD
44
<?php
45
/**
46
 * Generated by yentu on $timestamp
47
 */
48
49
HEAD;
50
        return $header . $this->lines;
51
    }
52
    
53
    public function getTimestamp()
54
    {
55
        return date('jS F, Y H:i:s T');
56
    }
57
}
58
59