MDL-70301 lib: Upgrade scssphp to 1.4.1
[moodle.git] / lib / scssphp / Formatter / Expanded.php
blobb7cbde18d83fbc4b73cd954668807f1a9cb0b81e
1 <?php
3 /**
4 * SCSSPHP
6 * @copyright 2012-2020 Leaf Corcoran
8 * @license http://opensource.org/licenses/MIT MIT
10 * @link http://scssphp.github.io/scssphp
13 namespace ScssPhp\ScssPhp\Formatter;
15 use ScssPhp\ScssPhp\Formatter;
17 /**
18 * Expanded formatter
20 * @author Leaf Corcoran <leafot@gmail.com>
22 class Expanded extends Formatter
24 /**
25 * {@inheritdoc}
27 public function __construct()
29 $this->indentLevel = 0;
30 $this->indentChar = ' ';
31 $this->break = "\n";
32 $this->open = ' {';
33 $this->close = '}';
34 $this->tagSeparator = ', ';
35 $this->assignSeparator = ': ';
36 $this->keepSemicolons = true;
39 /**
40 * {@inheritdoc}
42 protected function indentStr()
44 return str_repeat($this->indentChar, $this->indentLevel);
47 /**
48 * {@inheritdoc}
50 protected function blockLines(OutputBlock $block)
52 $inner = $this->indentStr();
54 $glue = $this->break . $inner;
56 foreach ($block->lines as $index => $line) {
57 if (substr($line, 0, 2) === '/*') {
58 $block->lines[$index] = preg_replace('/\r\n?|\n|\f/', $this->break, $line);
62 $this->write($inner . implode($glue, $block->lines));
64 if (empty($block->selectors) || ! empty($block->children)) {
65 $this->write($this->break);