Leafo\ScssPhp\Compiler::throwError PHP Method

throwError() public method

Throw error (exception)
public throwError ( string $msg )
$msg string Message with optional sprintf()-style vararg parameters
    public function throwError($msg)
    {
        if ($this->ignoreErrors) {
            return;
        }
        if (func_num_args() > 1) {
            $msg = call_user_func_array('sprintf', func_get_args());
        }
        $line = $this->sourceLine;
        $msg = "{$msg}: line: {$line}";
        throw new CompilerException($msg);
    }

Usage Example

Example #1
0
 /**
  * Output number
  *
  * @param \Leafo\ScssPhp\Compiler $compiler
  *
  * @return string
  */
 public function output(Compiler $compiler = null)
 {
     $dimension = round($this->dimension, self::$precision);
     $units = array_filter($this->units, function ($unitSize) {
         return $unitSize;
     });
     // @todo refactor normalize()
     if (count($units) > 1 && array_sum($units) === 0) {
         $dimension = $this->dimension;
         $units = array();
         $this->normalizeUnits($dimension, $units, 'in');
         $dimension = round($dimension, self::$precision);
         $units = array_filter($units, function ($unitSize) {
             return $unitSize;
         });
     }
     $unitSize = array_sum($units);
     if ($compiler && ($unitSize > 1 || $unitSize < 0 || count($units) > 1)) {
         $compiler->throwError((string) $dimension . $this->unitStr() . " isn't a valid CSS value.");
     }
     reset($units);
     list($unit, ) = each($units);
     return (string) $dimension . $unit;
 }
Compiler