throwError() public method

Throw error (exception)
public throwError ( string $msg )
$msg string Message with optional sprintf()-style vararg parameters
Ejemplo n.º 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;
 }