Format   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 46
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 4
lcom 1
cbo 1
dl 0
loc 46
ccs 9
cts 9
cp 1
rs 10
c 0
b 0
f 0

4 Methods

Rating   Name   Duplication   Size   Complexity  
A string() 0 4 1
A setTabSize() 0 4 1
A begin() 0 4 1
A end() 0 4 1
1
<?php
2
3
namespace BestServedCold\HTMLBuilder\Output;
4
5
use BestServedCold\HTMLBuilder\Html\Node;
6
7
/**
8
 * Class Format
9
 *
10
 * @package BestServedCold\HTMLBuilder\Output
11
 */
12
abstract class Format
13
{
14
    /**
15
     * @var int $tabSize
16
     */
17
    private static $tabSize = 4;
18
19
    /**
20
     * @param  string $string
21
     * @param  int    $depth
22
     * @return string
23
     */
24 3
    public static function string($string, $depth)
25
    {
26 3
        return str_pad($string, strlen($string) + ($depth * self::$tabSize), ' ', STR_PAD_LEFT) . PHP_EOL;
27
    }
28
29
    /**
30
     * @param int $tabSize
31
     */
32 1
    public static function setTabSize($tabSize)
33
    {
34 1
        self::$tabSize = $tabSize;
35 1
    }
36
37
    /**
38
     * @param  Node   $node
39
     * @param  string $attributes
40
     * @param  int    $depth
41
     * @return string
42
     */
43 3
    public static function begin(Node $node, $attributes, $depth)
44
    {
45 3
        return self::string('<' . $node->getType()  . $attributes . '>', $depth);
46
    }
47
48
    /**
49
     * @param  Node   $node
50
     * @param  int    $depth
51
     * @return string
52
     */
53 3
    public static function end(Node $node, $depth)
54
    {
55 3
        return self::string('</' . $node->getType() . '>', $depth);
56
    }
57
}
58