@@ -21,48 +21,48 @@ |
||
| 21 | 21 | */ |
| 22 | 22 | class Expanded extends Formatter |
| 23 | 23 | { |
| 24 | - /** |
|
| 25 | - * {@inheritdoc} |
|
| 26 | - */ |
|
| 27 | - public function __construct() |
|
| 28 | - { |
|
| 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; |
|
| 37 | - } |
|
| 24 | + /** |
|
| 25 | + * {@inheritdoc} |
|
| 26 | + */ |
|
| 27 | + public function __construct() |
|
| 28 | + { |
|
| 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; |
|
| 37 | + } |
|
| 38 | 38 | |
| 39 | - /** |
|
| 40 | - * {@inheritdoc} |
|
| 41 | - */ |
|
| 42 | - protected function indentStr() |
|
| 43 | - { |
|
| 44 | - return str_repeat($this->indentChar, $this->indentLevel); |
|
| 45 | - } |
|
| 39 | + /** |
|
| 40 | + * {@inheritdoc} |
|
| 41 | + */ |
|
| 42 | + protected function indentStr() |
|
| 43 | + { |
|
| 44 | + return str_repeat($this->indentChar, $this->indentLevel); |
|
| 45 | + } |
|
| 46 | 46 | |
| 47 | - /** |
|
| 48 | - * {@inheritdoc} |
|
| 49 | - */ |
|
| 50 | - protected function blockLines(OutputBlock $block) |
|
| 51 | - { |
|
| 52 | - $inner = $this->indentStr(); |
|
| 47 | + /** |
|
| 48 | + * {@inheritdoc} |
|
| 49 | + */ |
|
| 50 | + protected function blockLines(OutputBlock $block) |
|
| 51 | + { |
|
| 52 | + $inner = $this->indentStr(); |
|
| 53 | 53 | |
| 54 | - $glue = $this->break . $inner; |
|
| 54 | + $glue = $this->break . $inner; |
|
| 55 | 55 | |
| 56 | - foreach ($block->lines as $index => $line) { |
|
| 57 | - if (substr($line, 0, 2) === '/*') { |
|
| 58 | - $block->lines[$index] = preg_replace('/(\r|\n)+/', $glue, $line); |
|
| 59 | - } |
|
| 60 | - } |
|
| 56 | + foreach ($block->lines as $index => $line) { |
|
| 57 | + if (substr($line, 0, 2) === '/*') { |
|
| 58 | + $block->lines[$index] = preg_replace('/(\r|\n)+/', $glue, $line); |
|
| 59 | + } |
|
| 60 | + } |
|
| 61 | 61 | |
| 62 | - $this->write($inner . implode($glue, $block->lines)); |
|
| 62 | + $this->write($inner . implode($glue, $block->lines)); |
|
| 63 | 63 | |
| 64 | - if (empty($block->selectors) || ! empty($block->children)) { |
|
| 65 | - $this->write($this->break); |
|
| 66 | - } |
|
| 67 | - } |
|
| 64 | + if (empty($block->selectors) || ! empty($block->children)) { |
|
| 65 | + $this->write($this->break); |
|
| 66 | + } |
|
| 67 | + } |
|
| 68 | 68 | } |
@@ -21,101 +21,101 @@ |
||
| 21 | 21 | */ |
| 22 | 22 | class Debug extends Formatter |
| 23 | 23 | { |
| 24 | - /** |
|
| 25 | - * {@inheritdoc} |
|
| 26 | - */ |
|
| 27 | - public function __construct() |
|
| 28 | - { |
|
| 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; |
|
| 37 | - } |
|
| 38 | - |
|
| 39 | - /** |
|
| 40 | - * {@inheritdoc} |
|
| 41 | - */ |
|
| 42 | - protected function indentStr() |
|
| 43 | - { |
|
| 44 | - return str_repeat(' ', $this->indentLevel); |
|
| 45 | - } |
|
| 46 | - |
|
| 47 | - /** |
|
| 48 | - * {@inheritdoc} |
|
| 49 | - */ |
|
| 50 | - protected function blockLines(OutputBlock $block) |
|
| 51 | - { |
|
| 52 | - $indent = $this->indentStr(); |
|
| 53 | - |
|
| 54 | - if (empty($block->lines)) { |
|
| 55 | - $this->write("{$indent}block->lines: []\n"); |
|
| 56 | - |
|
| 57 | - return; |
|
| 58 | - } |
|
| 59 | - |
|
| 60 | - foreach ($block->lines as $index => $line) { |
|
| 61 | - $this->write("{$indent}block->lines[{$index}]: $line\n"); |
|
| 62 | - } |
|
| 63 | - } |
|
| 64 | - |
|
| 65 | - /** |
|
| 66 | - * {@inheritdoc} |
|
| 67 | - */ |
|
| 68 | - protected function blockSelectors(OutputBlock $block) |
|
| 69 | - { |
|
| 70 | - $indent = $this->indentStr(); |
|
| 71 | - |
|
| 72 | - if (empty($block->selectors)) { |
|
| 73 | - $this->write("{$indent}block->selectors: []\n"); |
|
| 74 | - |
|
| 75 | - return; |
|
| 76 | - } |
|
| 77 | - |
|
| 78 | - foreach ($block->selectors as $index => $selector) { |
|
| 79 | - $this->write("{$indent}block->selectors[{$index}]: $selector\n"); |
|
| 80 | - } |
|
| 81 | - } |
|
| 82 | - |
|
| 83 | - /** |
|
| 84 | - * {@inheritdoc} |
|
| 85 | - */ |
|
| 86 | - protected function blockChildren(OutputBlock $block) |
|
| 87 | - { |
|
| 88 | - $indent = $this->indentStr(); |
|
| 89 | - |
|
| 90 | - if (empty($block->children)) { |
|
| 91 | - $this->write("{$indent}block->children: []\n"); |
|
| 92 | - |
|
| 93 | - return; |
|
| 94 | - } |
|
| 95 | - |
|
| 96 | - $this->indentLevel++; |
|
| 97 | - |
|
| 98 | - foreach ($block->children as $i => $child) { |
|
| 99 | - $this->block($child); |
|
| 100 | - } |
|
| 101 | - |
|
| 102 | - $this->indentLevel--; |
|
| 103 | - } |
|
| 104 | - |
|
| 105 | - /** |
|
| 106 | - * {@inheritdoc} |
|
| 107 | - */ |
|
| 108 | - protected function block(OutputBlock $block) |
|
| 109 | - { |
|
| 110 | - $indent = $this->indentStr(); |
|
| 111 | - |
|
| 112 | - $this->write("{$indent}block->type: {$block->type}\n" . |
|
| 113 | - "{$indent}block->depth: {$block->depth}\n"); |
|
| 114 | - |
|
| 115 | - $this->currentBlock = $block; |
|
| 116 | - |
|
| 117 | - $this->blockSelectors($block); |
|
| 118 | - $this->blockLines($block); |
|
| 119 | - $this->blockChildren($block); |
|
| 120 | - } |
|
| 24 | + /** |
|
| 25 | + * {@inheritdoc} |
|
| 26 | + */ |
|
| 27 | + public function __construct() |
|
| 28 | + { |
|
| 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; |
|
| 37 | + } |
|
| 38 | + |
|
| 39 | + /** |
|
| 40 | + * {@inheritdoc} |
|
| 41 | + */ |
|
| 42 | + protected function indentStr() |
|
| 43 | + { |
|
| 44 | + return str_repeat(' ', $this->indentLevel); |
|
| 45 | + } |
|
| 46 | + |
|
| 47 | + /** |
|
| 48 | + * {@inheritdoc} |
|
| 49 | + */ |
|
| 50 | + protected function blockLines(OutputBlock $block) |
|
| 51 | + { |
|
| 52 | + $indent = $this->indentStr(); |
|
| 53 | + |
|
| 54 | + if (empty($block->lines)) { |
|
| 55 | + $this->write("{$indent}block->lines: []\n"); |
|
| 56 | + |
|
| 57 | + return; |
|
| 58 | + } |
|
| 59 | + |
|
| 60 | + foreach ($block->lines as $index => $line) { |
|
| 61 | + $this->write("{$indent}block->lines[{$index}]: $line\n"); |
|
| 62 | + } |
|
| 63 | + } |
|
| 64 | + |
|
| 65 | + /** |
|
| 66 | + * {@inheritdoc} |
|
| 67 | + */ |
|
| 68 | + protected function blockSelectors(OutputBlock $block) |
|
| 69 | + { |
|
| 70 | + $indent = $this->indentStr(); |
|
| 71 | + |
|
| 72 | + if (empty($block->selectors)) { |
|
| 73 | + $this->write("{$indent}block->selectors: []\n"); |
|
| 74 | + |
|
| 75 | + return; |
|
| 76 | + } |
|
| 77 | + |
|
| 78 | + foreach ($block->selectors as $index => $selector) { |
|
| 79 | + $this->write("{$indent}block->selectors[{$index}]: $selector\n"); |
|
| 80 | + } |
|
| 81 | + } |
|
| 82 | + |
|
| 83 | + /** |
|
| 84 | + * {@inheritdoc} |
|
| 85 | + */ |
|
| 86 | + protected function blockChildren(OutputBlock $block) |
|
| 87 | + { |
|
| 88 | + $indent = $this->indentStr(); |
|
| 89 | + |
|
| 90 | + if (empty($block->children)) { |
|
| 91 | + $this->write("{$indent}block->children: []\n"); |
|
| 92 | + |
|
| 93 | + return; |
|
| 94 | + } |
|
| 95 | + |
|
| 96 | + $this->indentLevel++; |
|
| 97 | + |
|
| 98 | + foreach ($block->children as $i => $child) { |
|
| 99 | + $this->block($child); |
|
| 100 | + } |
|
| 101 | + |
|
| 102 | + $this->indentLevel--; |
|
| 103 | + } |
|
| 104 | + |
|
| 105 | + /** |
|
| 106 | + * {@inheritdoc} |
|
| 107 | + */ |
|
| 108 | + protected function block(OutputBlock $block) |
|
| 109 | + { |
|
| 110 | + $indent = $this->indentStr(); |
|
| 111 | + |
|
| 112 | + $this->write("{$indent}block->type: {$block->type}\n" . |
|
| 113 | + "{$indent}block->depth: {$block->depth}\n"); |
|
| 114 | + |
|
| 115 | + $this->currentBlock = $block; |
|
| 116 | + |
|
| 117 | + $this->blockSelectors($block); |
|
| 118 | + $this->blockLines($block); |
|
| 119 | + $this->blockChildren($block); |
|
| 120 | + } |
|
| 121 | 121 | } |
@@ -18,48 +18,48 @@ |
||
| 18 | 18 | */ |
| 19 | 19 | class OutputBlock |
| 20 | 20 | { |
| 21 | - /** |
|
| 22 | - * @var string |
|
| 23 | - */ |
|
| 24 | - public $type; |
|
| 21 | + /** |
|
| 22 | + * @var string |
|
| 23 | + */ |
|
| 24 | + public $type; |
|
| 25 | 25 | |
| 26 | - /** |
|
| 27 | - * @var integer |
|
| 28 | - */ |
|
| 29 | - public $depth; |
|
| 26 | + /** |
|
| 27 | + * @var integer |
|
| 28 | + */ |
|
| 29 | + public $depth; |
|
| 30 | 30 | |
| 31 | - /** |
|
| 32 | - * @var array |
|
| 33 | - */ |
|
| 34 | - public $selectors; |
|
| 31 | + /** |
|
| 32 | + * @var array |
|
| 33 | + */ |
|
| 34 | + public $selectors; |
|
| 35 | 35 | |
| 36 | - /** |
|
| 37 | - * @var array |
|
| 38 | - */ |
|
| 39 | - public $lines; |
|
| 36 | + /** |
|
| 37 | + * @var array |
|
| 38 | + */ |
|
| 39 | + public $lines; |
|
| 40 | 40 | |
| 41 | - /** |
|
| 42 | - * @var array |
|
| 43 | - */ |
|
| 44 | - public $children; |
|
| 41 | + /** |
|
| 42 | + * @var array |
|
| 43 | + */ |
|
| 44 | + public $children; |
|
| 45 | 45 | |
| 46 | - /** |
|
| 47 | - * @var \Leafo\ScssPhp\Formatter\OutputBlock |
|
| 48 | - */ |
|
| 49 | - public $parent; |
|
| 46 | + /** |
|
| 47 | + * @var \Leafo\ScssPhp\Formatter\OutputBlock |
|
| 48 | + */ |
|
| 49 | + public $parent; |
|
| 50 | 50 | |
| 51 | - /** |
|
| 52 | - * @var string |
|
| 53 | - */ |
|
| 54 | - public $sourceName; |
|
| 51 | + /** |
|
| 52 | + * @var string |
|
| 53 | + */ |
|
| 54 | + public $sourceName; |
|
| 55 | 55 | |
| 56 | - /** |
|
| 57 | - * @var integer |
|
| 58 | - */ |
|
| 59 | - public $sourceLine; |
|
| 56 | + /** |
|
| 57 | + * @var integer |
|
| 58 | + */ |
|
| 59 | + public $sourceLine; |
|
| 60 | 60 | |
| 61 | - /** |
|
| 62 | - * @var integer |
|
| 63 | - */ |
|
| 64 | - public $sourceColumn; |
|
| 61 | + /** |
|
| 62 | + * @var integer |
|
| 63 | + */ |
|
| 64 | + public $sourceColumn; |
|
| 65 | 65 | } |
@@ -21,42 +21,42 @@ |
||
| 21 | 21 | */ |
| 22 | 22 | class Compressed extends Formatter |
| 23 | 23 | { |
| 24 | - /** |
|
| 25 | - * {@inheritdoc} |
|
| 26 | - */ |
|
| 27 | - public function __construct() |
|
| 28 | - { |
|
| 29 | - $this->indentLevel = 0; |
|
| 30 | - $this->indentChar = ' '; |
|
| 31 | - $this->break = ''; |
|
| 32 | - $this->open = '{'; |
|
| 33 | - $this->close = '}'; |
|
| 34 | - $this->tagSeparator = ','; |
|
| 35 | - $this->assignSeparator = ':'; |
|
| 36 | - $this->keepSemicolons = false; |
|
| 37 | - } |
|
| 38 | - |
|
| 39 | - /** |
|
| 40 | - * {@inheritdoc} |
|
| 41 | - */ |
|
| 42 | - public function blockLines(OutputBlock $block) |
|
| 43 | - { |
|
| 44 | - $inner = $this->indentStr(); |
|
| 45 | - |
|
| 46 | - $glue = $this->break . $inner; |
|
| 47 | - |
|
| 48 | - foreach ($block->lines as $index => $line) { |
|
| 49 | - if (substr($line, 0, 2) === '/*' && substr($line, 2, 1) !== '!') { |
|
| 50 | - unset($block->lines[$index]); |
|
| 51 | - } elseif (substr($line, 0, 3) === '/*!') { |
|
| 52 | - $block->lines[$index] = '/*' . substr($line, 3); |
|
| 53 | - } |
|
| 54 | - } |
|
| 55 | - |
|
| 56 | - $this->write($inner . implode($glue, $block->lines)); |
|
| 57 | - |
|
| 58 | - if (! empty($block->children)) { |
|
| 59 | - $this->write($this->break); |
|
| 60 | - } |
|
| 61 | - } |
|
| 24 | + /** |
|
| 25 | + * {@inheritdoc} |
|
| 26 | + */ |
|
| 27 | + public function __construct() |
|
| 28 | + { |
|
| 29 | + $this->indentLevel = 0; |
|
| 30 | + $this->indentChar = ' '; |
|
| 31 | + $this->break = ''; |
|
| 32 | + $this->open = '{'; |
|
| 33 | + $this->close = '}'; |
|
| 34 | + $this->tagSeparator = ','; |
|
| 35 | + $this->assignSeparator = ':'; |
|
| 36 | + $this->keepSemicolons = false; |
|
| 37 | + } |
|
| 38 | + |
|
| 39 | + /** |
|
| 40 | + * {@inheritdoc} |
|
| 41 | + */ |
|
| 42 | + public function blockLines(OutputBlock $block) |
|
| 43 | + { |
|
| 44 | + $inner = $this->indentStr(); |
|
| 45 | + |
|
| 46 | + $glue = $this->break . $inner; |
|
| 47 | + |
|
| 48 | + foreach ($block->lines as $index => $line) { |
|
| 49 | + if (substr($line, 0, 2) === '/*' && substr($line, 2, 1) !== '!') { |
|
| 50 | + unset($block->lines[$index]); |
|
| 51 | + } elseif (substr($line, 0, 3) === '/*!') { |
|
| 52 | + $block->lines[$index] = '/*' . substr($line, 3); |
|
| 53 | + } |
|
| 54 | + } |
|
| 55 | + |
|
| 56 | + $this->write($inner . implode($glue, $block->lines)); |
|
| 57 | + |
|
| 58 | + if (! empty($block->children)) { |
|
| 59 | + $this->write($this->break); |
|
| 60 | + } |
|
| 61 | + } |
|
| 62 | 62 | } |
@@ -55,7 +55,7 @@ |
||
| 55 | 55 | |
| 56 | 56 | $this->write($inner . implode($glue, $block->lines)); |
| 57 | 57 | |
| 58 | - if (! empty($block->children)) { |
|
| 58 | + if ( ! empty($block->children)) { |
|
| 59 | 59 | $this->write($this->break); |
| 60 | 60 | } |
| 61 | 61 | } |
@@ -21,40 +21,40 @@ |
||
| 21 | 21 | */ |
| 22 | 22 | class Crunched extends Formatter |
| 23 | 23 | { |
| 24 | - /** |
|
| 25 | - * {@inheritdoc} |
|
| 26 | - */ |
|
| 27 | - public function __construct() |
|
| 28 | - { |
|
| 29 | - $this->indentLevel = 0; |
|
| 30 | - $this->indentChar = ' '; |
|
| 31 | - $this->break = ''; |
|
| 32 | - $this->open = '{'; |
|
| 33 | - $this->close = '}'; |
|
| 34 | - $this->tagSeparator = ','; |
|
| 35 | - $this->assignSeparator = ':'; |
|
| 36 | - $this->keepSemicolons = false; |
|
| 37 | - } |
|
| 38 | - |
|
| 39 | - /** |
|
| 40 | - * {@inheritdoc} |
|
| 41 | - */ |
|
| 42 | - public function blockLines(OutputBlock $block) |
|
| 43 | - { |
|
| 44 | - $inner = $this->indentStr(); |
|
| 45 | - |
|
| 46 | - $glue = $this->break . $inner; |
|
| 47 | - |
|
| 48 | - foreach ($block->lines as $index => $line) { |
|
| 49 | - if (substr($line, 0, 2) === '/*') { |
|
| 50 | - unset($block->lines[$index]); |
|
| 51 | - } |
|
| 52 | - } |
|
| 53 | - |
|
| 54 | - $this->write($inner . implode($glue, $block->lines)); |
|
| 55 | - |
|
| 56 | - if (! empty($block->children)) { |
|
| 57 | - $this->write($this->break); |
|
| 58 | - } |
|
| 59 | - } |
|
| 24 | + /** |
|
| 25 | + * {@inheritdoc} |
|
| 26 | + */ |
|
| 27 | + public function __construct() |
|
| 28 | + { |
|
| 29 | + $this->indentLevel = 0; |
|
| 30 | + $this->indentChar = ' '; |
|
| 31 | + $this->break = ''; |
|
| 32 | + $this->open = '{'; |
|
| 33 | + $this->close = '}'; |
|
| 34 | + $this->tagSeparator = ','; |
|
| 35 | + $this->assignSeparator = ':'; |
|
| 36 | + $this->keepSemicolons = false; |
|
| 37 | + } |
|
| 38 | + |
|
| 39 | + /** |
|
| 40 | + * {@inheritdoc} |
|
| 41 | + */ |
|
| 42 | + public function blockLines(OutputBlock $block) |
|
| 43 | + { |
|
| 44 | + $inner = $this->indentStr(); |
|
| 45 | + |
|
| 46 | + $glue = $this->break . $inner; |
|
| 47 | + |
|
| 48 | + foreach ($block->lines as $index => $line) { |
|
| 49 | + if (substr($line, 0, 2) === '/*') { |
|
| 50 | + unset($block->lines[$index]); |
|
| 51 | + } |
|
| 52 | + } |
|
| 53 | + |
|
| 54 | + $this->write($inner . implode($glue, $block->lines)); |
|
| 55 | + |
|
| 56 | + if (! empty($block->children)) { |
|
| 57 | + $this->write($this->break); |
|
| 58 | + } |
|
| 59 | + } |
|
| 60 | 60 | } |
@@ -53,7 +53,7 @@ |
||
| 53 | 53 | |
| 54 | 54 | $this->write($inner . implode($glue, $block->lines)); |
| 55 | 55 | |
| 56 | - if (! empty($block->children)) { |
|
| 56 | + if ( ! empty($block->children)) { |
|
| 57 | 57 | $this->write($this->break); |
| 58 | 58 | } |
| 59 | 59 | } |
@@ -20,26 +20,26 @@ |
||
| 20 | 20 | */ |
| 21 | 21 | class Compact extends Formatter |
| 22 | 22 | { |
| 23 | - /** |
|
| 24 | - * {@inheritdoc} |
|
| 25 | - */ |
|
| 26 | - public function __construct() |
|
| 27 | - { |
|
| 28 | - $this->indentLevel = 0; |
|
| 29 | - $this->indentChar = ''; |
|
| 30 | - $this->break = ''; |
|
| 31 | - $this->open = ' {'; |
|
| 32 | - $this->close = "}\n\n"; |
|
| 33 | - $this->tagSeparator = ','; |
|
| 34 | - $this->assignSeparator = ':'; |
|
| 35 | - $this->keepSemicolons = true; |
|
| 36 | - } |
|
| 23 | + /** |
|
| 24 | + * {@inheritdoc} |
|
| 25 | + */ |
|
| 26 | + public function __construct() |
|
| 27 | + { |
|
| 28 | + $this->indentLevel = 0; |
|
| 29 | + $this->indentChar = ''; |
|
| 30 | + $this->break = ''; |
|
| 31 | + $this->open = ' {'; |
|
| 32 | + $this->close = "}\n\n"; |
|
| 33 | + $this->tagSeparator = ','; |
|
| 34 | + $this->assignSeparator = ':'; |
|
| 35 | + $this->keepSemicolons = true; |
|
| 36 | + } |
|
| 37 | 37 | |
| 38 | - /** |
|
| 39 | - * {@inheritdoc} |
|
| 40 | - */ |
|
| 41 | - public function indentStr() |
|
| 42 | - { |
|
| 43 | - return ' '; |
|
| 44 | - } |
|
| 38 | + /** |
|
| 39 | + * {@inheritdoc} |
|
| 40 | + */ |
|
| 41 | + public function indentStr() |
|
| 42 | + { |
|
| 43 | + return ' '; |
|
| 44 | + } |
|
| 45 | 45 | } |
@@ -21,50 +21,50 @@ |
||
| 21 | 21 | */ |
| 22 | 22 | class Util |
| 23 | 23 | { |
| 24 | - /** |
|
| 25 | - * Asserts that `value` falls within `range` (inclusive), leaving |
|
| 26 | - * room for slight floating-point errors. |
|
| 27 | - * |
|
| 28 | - * @param string $name The name of the value. Used in the error message. |
|
| 29 | - * @param \Leafo\ScssPhp\Base\Range $range Range of values. |
|
| 30 | - * @param array $value The value to check. |
|
| 31 | - * @param string $unit The unit of the value. Used in error reporting. |
|
| 32 | - * |
|
| 33 | - * @return mixed `value` adjusted to fall within range, if it was outside by a floating-point margin. |
|
| 34 | - * |
|
| 35 | - * @throws \Leafo\ScssPhp\Exception\RangeException |
|
| 36 | - */ |
|
| 37 | - public static function checkRange($name, Range $range, $value, $unit = '') |
|
| 38 | - { |
|
| 39 | - $val = $value[1]; |
|
| 40 | - $grace = new Range(-0.00001, 0.00001); |
|
| 24 | + /** |
|
| 25 | + * Asserts that `value` falls within `range` (inclusive), leaving |
|
| 26 | + * room for slight floating-point errors. |
|
| 27 | + * |
|
| 28 | + * @param string $name The name of the value. Used in the error message. |
|
| 29 | + * @param \Leafo\ScssPhp\Base\Range $range Range of values. |
|
| 30 | + * @param array $value The value to check. |
|
| 31 | + * @param string $unit The unit of the value. Used in error reporting. |
|
| 32 | + * |
|
| 33 | + * @return mixed `value` adjusted to fall within range, if it was outside by a floating-point margin. |
|
| 34 | + * |
|
| 35 | + * @throws \Leafo\ScssPhp\Exception\RangeException |
|
| 36 | + */ |
|
| 37 | + public static function checkRange($name, Range $range, $value, $unit = '') |
|
| 38 | + { |
|
| 39 | + $val = $value[1]; |
|
| 40 | + $grace = new Range(-0.00001, 0.00001); |
|
| 41 | 41 | |
| 42 | - if ($range->includes($val)) { |
|
| 43 | - return $val; |
|
| 44 | - } |
|
| 42 | + if ($range->includes($val)) { |
|
| 43 | + return $val; |
|
| 44 | + } |
|
| 45 | 45 | |
| 46 | - if ($grace->includes($val - $range->first)) { |
|
| 47 | - return $range->first; |
|
| 48 | - } |
|
| 46 | + if ($grace->includes($val - $range->first)) { |
|
| 47 | + return $range->first; |
|
| 48 | + } |
|
| 49 | 49 | |
| 50 | - if ($grace->includes($val - $range->last)) { |
|
| 51 | - return $range->last; |
|
| 52 | - } |
|
| 50 | + if ($grace->includes($val - $range->last)) { |
|
| 51 | + return $range->last; |
|
| 52 | + } |
|
| 53 | 53 | |
| 54 | - throw new RangeException("$name {$val} must be between {$range->first} and {$range->last}$unit"); |
|
| 55 | - } |
|
| 54 | + throw new RangeException("$name {$val} must be between {$range->first} and {$range->last}$unit"); |
|
| 55 | + } |
|
| 56 | 56 | |
| 57 | - /** |
|
| 58 | - * Encode URI component |
|
| 59 | - * |
|
| 60 | - * @param string $string |
|
| 61 | - * |
|
| 62 | - * @return string |
|
| 63 | - */ |
|
| 64 | - public static function encodeURIComponent($string) |
|
| 65 | - { |
|
| 66 | - $revert = array('%21' => '!', '%2A' => '*', '%27' => "'", '%28' => '(', '%29' => ')'); |
|
| 57 | + /** |
|
| 58 | + * Encode URI component |
|
| 59 | + * |
|
| 60 | + * @param string $string |
|
| 61 | + * |
|
| 62 | + * @return string |
|
| 63 | + */ |
|
| 64 | + public static function encodeURIComponent($string) |
|
| 65 | + { |
|
| 66 | + $revert = array('%21' => '!', '%2A' => '*', '%27' => "'", '%28' => '(', '%29' => ')'); |
|
| 67 | 67 | |
| 68 | - return strtr(rawurlencode($string), $revert); |
|
| 69 | - } |
|
| 68 | + return strtr(rawurlencode($string), $revert); |
|
| 69 | + } |
|
| 70 | 70 | } |