Proyectos de Subversion Moodle

Rev

| Ultima modificación | Ver Log |

Rev Autor Línea Nro. Línea
1 efrain 1
<?php
2
 
3
/**
4
 * SCSSPHP
5
 *
6
 * @copyright 2012-2020 Leaf Corcoran
7
 *
8
 * @license http://opensource.org/licenses/MIT MIT
9
 *
10
 * @link http://scssphp.github.io/scssphp
11
 */
12
 
13
namespace ScssPhp\ScssPhp\Formatter;
14
 
15
use ScssPhp\ScssPhp\Formatter;
16
 
17
/**
18
 * Debug formatter
19
 *
20
 * @author Anthon Pang <anthon.pang@gmail.com>
21
 *
22
 * @deprecated since 1.4.0.
23
 *
24
 * @internal
25
 */
26
class Debug extends Formatter
27
{
28
    /**
29
     * {@inheritdoc}
30
     */
31
    public function __construct()
32
    {
33
        @trigger_error('The Debug formatter is deprecated since 1.4.0.', E_USER_DEPRECATED);
34
 
35
        $this->indentLevel = 0;
36
        $this->indentChar = '';
37
        $this->break = "\n";
38
        $this->open = ' {';
39
        $this->close = ' }';
40
        $this->tagSeparator = ', ';
41
        $this->assignSeparator = ': ';
42
        $this->keepSemicolons = true;
43
    }
44
 
45
    /**
46
     * {@inheritdoc}
47
     */
48
    protected function indentStr()
49
    {
50
        return str_repeat('  ', $this->indentLevel);
51
    }
52
 
53
    /**
54
     * {@inheritdoc}
55
     */
56
    protected function blockLines(OutputBlock $block)
57
    {
58
        $indent = $this->indentStr();
59
 
60
        if (empty($block->lines)) {
61
            $this->write("{$indent}block->lines: []\n");
62
 
63
            return;
64
        }
65
 
66
        foreach ($block->lines as $index => $line) {
67
            $this->write("{$indent}block->lines[{$index}]: $line\n");
68
        }
69
    }
70
 
71
    /**
72
     * {@inheritdoc}
73
     */
74
    protected function blockSelectors(OutputBlock $block)
75
    {
76
        $indent = $this->indentStr();
77
 
78
        if (empty($block->selectors)) {
79
            $this->write("{$indent}block->selectors: []\n");
80
 
81
            return;
82
        }
83
 
84
        foreach ($block->selectors as $index => $selector) {
85
            $this->write("{$indent}block->selectors[{$index}]: $selector\n");
86
        }
87
    }
88
 
89
    /**
90
     * {@inheritdoc}
91
     */
92
    protected function blockChildren(OutputBlock $block)
93
    {
94
        $indent = $this->indentStr();
95
 
96
        if (empty($block->children)) {
97
            $this->write("{$indent}block->children: []\n");
98
 
99
            return;
100
        }
101
 
102
        $this->indentLevel++;
103
 
104
        foreach ($block->children as $i => $child) {
105
            $this->block($child);
106
        }
107
 
108
        $this->indentLevel--;
109
    }
110
 
111
    /**
112
     * {@inheritdoc}
113
     */
114
    protected function block(OutputBlock $block)
115
    {
116
        $indent = $this->indentStr();
117
 
118
        $this->write("{$indent}block->type: {$block->type}\n" .
119
             "{$indent}block->depth: {$block->depth}\n");
120
 
121
        $this->currentBlock = $block;
122
 
123
        $this->blockSelectors($block);
124
        $this->blockLines($block);
125
        $this->blockChildren($block);
126
    }
127
}