Search moodle.org's
Developer Documentation

See Release Notes

  • Bug fixes for general core bugs in 3.11.x will end 14 Nov 2022 (12 months plus 6 months extension).
  • Bug fixes for security issues in 3.11.x will end 13 Nov 2023 (18 months plus 12 months extension).
  • PHP version: minimum PHP 7.3.0 Note: minimum PHP version has increased since Moodle 3.10. PHP 7.4.x is supported too.

Differences Between: [Versions 310 and 311] [Versions 311 and 400] [Versions 311 and 401] [Versions 311 and 402] [Versions 311 and 403] [Versions 39 and 311]

   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   * Crunched formatter
  19   *
  20   * @author Anthon Pang <anthon.pang@gmail.com>
  21   *
  22   * @deprecated since 1.4.0. Use the Compressed formatter instead.
  23   */
  24  class Crunched extends Formatter
  25  {
  26      /**
  27       * {@inheritdoc}
  28       */
  29      public function __construct()
  30      {
  31          @trigger_error('The Crunched formatter is deprecated since 1.4.0. Use the Compressed formatter instead.', E_USER_DEPRECATED);
  32  
  33          $this->indentLevel = 0;
  34          $this->indentChar = '  ';
  35          $this->break = '';
  36          $this->open = '{';
  37          $this->close = '}';
  38          $this->tagSeparator = ',';
  39          $this->assignSeparator = ':';
  40          $this->keepSemicolons = false;
  41      }
  42  
  43      /**
  44       * {@inheritdoc}
  45       */
  46      public function blockLines(OutputBlock $block)
  47      {
  48          $inner = $this->indentStr();
  49  
  50          $glue = $this->break . $inner;
  51  
  52          foreach ($block->lines as $index => $line) {
  53              if (substr($line, 0, 2) === '/*') {
  54                  unset($block->lines[$index]);
  55              }
  56          }
  57  
  58          $this->write($inner . implode($glue, $block->lines));
  59  
  60          if (! empty($block->children)) {
  61              $this->write($this->break);
  62          }
  63      }
  64  
  65      /**
  66       * Output block selectors
  67       *
  68       * @param \ScssPhp\ScssPhp\Formatter\OutputBlock $block
  69       */
  70      protected function blockSelectors(OutputBlock $block)
  71      {
  72          $inner = $this->indentStr();
  73  
  74          $this->write(
  75              $inner
  76              . implode(
  77                  $this->tagSeparator,
  78                  str_replace([' > ', ' + ', ' ~ '], ['>', '+', '~'], $block->selectors)
  79              )
  80              . $this->open . $this->break
  81          );
  82      }
  83  }