You are here

public static function SassLiteral::assertInRange in Sassy 7

Same name and namespace in other branches
  1. 7.3 phpsass/script/literals/SassLiteral.php \SassLiteral::assertInRange()

* Asserts that the value of a literal is within the expected range *

Parameters

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

4 calls to SassLiteral::assertInRange()
SassScriptFunctions::adjust in phamlp/sass/script/SassScriptFunctions.php
* Adjusts the colour *
SassScriptFunctions::hsla in phamlp/sass/script/SassScriptFunctions.php
* Creates a SassColour object from hue, saturation, lightness and alpha * channel (opacity). *
SassScriptFunctions::mix in phamlp/sass/script/SassScriptFunctions.php
* Mixes two colours together. * Takes the average of each of the RGB components, optionally weighted by the * given percentage. The opacity of the colours is also considered when * weighting the components. * The weight specifies the amount of…
SassScriptFunctions::rgba in phamlp/sass/script/SassScriptFunctions.php
* Creates a SassColour object from red, green, and blue values and alpha * channel (opacity). * There are two overloads: * * rgba(red, green, blue, alpha) *

File

phamlp/sass/script/literals/SassLiteral.php, line 344

Class

SassLiteral
SassLiteral class. Base class for all Sass literals. Sass data types are extended from this class and these override the operation methods to provide the appropriate semantics. @package PHamlP @subpackage Sass.script.literals

Code

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);
  }
}