Esempio n. 1
0
 /**
  * String multiplication.
  * this is repeated other times
  * @param sassNumber the number of times to repeat this
  * @return sassString the string result
  */
 public function op_times($other)
 {
     if (!$other instanceof SassNumber || !$other->isUnitless()) {
         throw new SassStringException('{what} must be a {type}', array('{what}' => Phamlp::t('sass', 'Value'), '{type}' => Phamlp::t('sass', 'unitless number')), SassScriptParser::$context->node);
     }
     $this->value = str_repeat($this->value, $other->value);
     return $this;
 }
Esempio n. 2
0
 /**
  * Parse this node.
  * This raises an error.
  * @return array An empty array
  */
 public function parse($context)
 {
     if (!$this->warning || $this->root->parser->quiet === false) {
         set_error_handler(array($this, 'errorHandler'));
         trigger_error($this->warning ? $this->interpolate(Phamlp::t('sass', $this->message, $this->params), $context) : $this->evaluate(Phamlp::t('sass', $this->message, $this->params), $context)->toString());
         restore_error_handler();
     }
     return array();
 }
Esempio n. 3
0
 /**
  * Takes the modulus (remainder) of this value divided by the value of other
  * 
  * @param
  *        	string value to divide by
  * @return mixed SassNumber if other is a SassNumber or
  *         SassColour if it is a SassColour
  */
 public function op_modulo($other)
 {
     if (!$other instanceof SassNumber || !$other->isUnitless()) {
         throw new SassNumberException('{what} must be a {type}', array('{what}' => Phamlp::t('sass', 'Number'), '{type}' => Phamlp::t('sass', 'unitless number')), SassScriptParser::$context->node);
     }
     $this->value %= $this->convert($other)->value;
     return $this;
 }
Esempio n. 4
0
 /**
  * Asserts that the value of a literal is within the expected range 
  * @param SassLiteral the literal to test
  * @param float the minimum value
  * @param float the maximum value
  * @param string the units.
  * @throws SassScriptFunctionException if value is not the expected type
  */
 public static function assertInRange($literal, $min, $max, $units = '')
 {
     if ($literal->value < $min || $literal->value > $max) {
         throw new SassScriptFunctionException('{what} must be {inRange}', array('{what}' => $literal->typeOf, '{inRange}' => Phamlp::t('sass', 'between {min} and {max} inclusive', array('{min}' => $min . $units, '{max}' => $max . $units))), SassScriptParser::$context->node);
     }
 }
Esempio n. 5
0
 /**
  * Colour bitwise Shift Right
  * @param sassNumber amount to shift right by
  * @return sassColour the colour result
  */
 public function op_shiftr($other)
 {
     if (!$other instanceof SassNumber || !$other->isUnitless()) {
         throw new SassColourException('{what} must be a {type}', array('{what}' => Phamlp::t('sass', 'Number'), '{type}' => Phamlp::t('sass', 'unitless number')), SassScriptParser::$context->node);
     }
     $this->red = $this->getRed() >> $other->value;
     $this->green = $this->getGreen() >> $other->value;
     $this->blue = $this->getBlue() >> $other->value;
     return $this;
 }
Esempio n. 6
0
 /**
  * Phamlp Exception.
  * 
  * @param
  *        	string Category (haml|sass)
  * @param
  *        	string Exception message
  * @param
  *        	array parameters to be applied to the message using <code>strtr</code>.
  */
 public function __construct($category, $message, $params, $object)
 {
     parent::__construct(Phamlp::t($category, $message, $params) . (is_object($object) ? ": {$object->filename}::{$object->line}\nSource: {$object->source}" : ''));
 }