PluginProbe
GetResponse Forms by Optin Cat / 1.4.2
GetResponse Forms by Optin Cat v1.4.2
1.3.4 1.3.5 1.3.6 1.3.8 1.3.9 1.4.0 1.4.1 1.4.2 1.5.0 1.5.1 1.5.2 1.5.4 1.5.5 1.5.6 1.5.7 1.5.8 1.6.1 1.6.2 1.6.3 1.7.0 1.7.1 1.7.2 1.8.0 1.8.1 2.0.0 All 36 releases
getresponse / includes / classes / scssphp / src / Formatter.php

Formatter.php in GetResponse Forms by Optin Cat 1.4.2, at includes/classes/scssphp/src/Formatter.php

94 lines 2.0 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * SCSSPHP
4 *
5 * @copyright 2012-2014 Leaf Corcoran
6 *
7 * @license http://opensource.org/licenses/gpl-license GPL-3.0
8 * @license http://opensource.org/licenses/MIT MIT
9 *
10 * @link http://leafo.net/scssphp
11 */
12
13 namespace Leafo\ScssPhp;
14
15 /**
16 * SCSS base formatter
17 *
18 * @author Leaf Corcoran <leafot@gmail.com>
19 */
20 abstract class Formatter
21 {
22 public $indentLevel;
23 public $indentChar;
24 public $break;
25 public $open;
26 public $close;
27 public $tagSeparator;
28 public $assignSeparator;
29
30 protected function indentStr($n = 0)
31 {
32 return str_repeat($this->indentChar, max($this->indentLevel + $n, 0));
33 }
34
35 public function property($name, $value)
36 {
37 return $name . $this->assignSeparator . $value . ';';
38 }
39
40 protected function blockLines($inner, $block)
41 {
42 $glue = $this->break.$inner;
43 echo $inner . implode($glue, $block->lines);
44
45 if (!empty($block->children)) {
46 echo $this->break;
47 }
48 }
49
50 protected function block($block)
51 {
52 if (empty($block->lines) && empty($block->children)) {
53 return;
54 }
55
56 $inner = $pre = $this->indentStr();
57
58 if (!empty($block->selectors)) {
59 echo $pre .
60 implode($this->tagSeparator, $block->selectors) .
61 $this->open . $this->break;
62 $this->indentLevel++;
63 $inner = $this->indentStr();
64 }
65
66 if (!empty($block->lines)) {
67 $this->blockLines($inner, $block);
68 }
69
70 foreach ($block->children as $child) {
71 $this->block($child);
72 }
73
74 if (!empty($block->selectors)) {
75 $this->indentLevel--;
76
77 if (empty($block->children)) {
78 echo $this->break;
79 }
80
81 echo $pre . $this->close . $this->break;
82 }
83 }
84
85 public function format($block)
86 {
87 ob_start();
88 $this->block($block);
89 $out = ob_get_clean();
90
91 return $out;
92 }
93 }
94