You are here

class SassBoolean in Sassy 7

Same name and namespace in other branches
  1. 7.3 phpsass/script/literals/SassBoolean.php \SassBoolean

SassBoolean class. @package PHamlP @subpackage Sass.script.literals

Hierarchy

Expanded class hierarchy of SassBoolean

4 string references to 'SassBoolean'
SassBoolean::__construct in phamlp/sass/script/literals/SassBoolean.php
* SassBoolean constructor *
SassExtentionsCompassFunctionsColourStops::grad_end_position in phamlp/sass/extensions/compass/functions/colourStops.php
SassExtentionsCompassFunctionsColourStops::grad_position in phamlp/sass/extensions/compass/functions/colourStops.php
SassScriptFunctions::adjust in phamlp/sass/script/SassScriptFunctions.php
* Adjusts the colour *

File

phamlp/sass/script/literals/SassBoolean.php, line 19

View source
class SassBoolean extends SassLiteral {

  /**@#+
   * Regex for matching and extracting booleans
   */
  const MATCH = '/^(true|false)\\b/';

  /**
   * SassBoolean constructor
   * @param string value of the boolean type
   * @return SassBoolean
   */
  public function __construct($value) {
    if (is_bool($value)) {
      $this->value = $value;
    }
    elseif ($value === 'true' || $value === 'false') {
      $this->value = $value === 'true' ? true : false;
    }
    else {
      throw new SassBooleanException('Invalid {what}', array(
        '{what}' => 'SassBoolean',
      ), SassScriptParser::$context->node);
    }
  }

  /**
   * Returns the value of this boolean.
   * @return boolean the value of this boolean
   */
  public function getValue() {
    return $this->value;
  }

  /**
   * Returns a string representation of the value.
   * @return string string representation of the value.
   */
  public function toString() {
    return $this
      ->getValue() ? 'true' : 'false';
  }

  /**
   * Returns a value indicating if a token of this type can be matched at
   * the start of the subject string.
   * @param string the subject string
   * @return mixed match at the start of the string or false if no match
   */
  public static function isa($subject) {
    return preg_match(self::MATCH, $subject, $matches) ? $matches[0] : false;
  }

}

Members

Namesort descending Modifiers Type Description Overrides
SassBoolean::getValue public function * Returns the value of this boolean. * Overrides SassLiteral::getValue
SassBoolean::isa public static function * Returns a value indicating if a token of this type can be matched at * the start of the subject string. * Overrides SassLiteral::isa
SassBoolean::MATCH constant
SassBoolean::toString public function * Returns a string representation of the value. * Overrides SassLiteral::toString
SassBoolean::__construct public function * SassBoolean constructor * Overrides SassLiteral::__construct
SassLiteral::$typeOf private static property *
SassLiteral::$value protected property *
SassLiteral::addChild public function * Adds a child object to this. *
SassLiteral::assertInRange public static function * Asserts that the value of a literal is within the expected range *
SassLiteral::assertType public static function * Asserts that the literal is the expected type *
SassLiteral::getTypeOf protected function * Returns the type of this * 1
SassLiteral::op_and public function * The SassScript and operation. *
SassLiteral::op_assign public function
SassLiteral::op_bw_and public function * Bitwise AND the value of other and this value * 1
SassLiteral::op_bw_not public function * Bitwise NOT the value of other and the value of this *
SassLiteral::op_bw_or public function * Bitwise OR the value of other and this value * 1
SassLiteral::op_bw_xor public function * Bitwise XOR the value of other and the value of this * 1
SassLiteral::op_comma public function * SassScript ',' operation. *
SassLiteral::op_concat public function * The SassScript default operation (e.g. $a $b, "foo" "bar"). *
SassLiteral::op_div public function * SassScript '/' operation. * 2
SassLiteral::op_eq public function * The SassScript == operation. * 1
SassLiteral::op_gt public function * The SassScript > operation. * 1
SassLiteral::op_gte public function * The SassScript >= operation. * 1
SassLiteral::op_lt public function * The SassScript < operation. * 1
SassLiteral::op_lte public function * The SassScript <= operation. * 1
SassLiteral::op_minus public function * SassScript '-' operation. * 2
SassLiteral::op_modulo public function * SassScript '%' operation. * 2
SassLiteral::op_neq public function * The SassScript != operation. *
SassLiteral::op_not public function * The SassScript not operation. * 1
SassLiteral::op_or public function * The SassScript or operation. *
SassLiteral::op_plus public function * SassScript '+' operation. * 3
SassLiteral::op_shiftl public function * Shifts the value of this left by the number of bits given in value * 1
SassLiteral::op_shiftr public function * Shifts the value of this right by the number of bits given in value * 1
SassLiteral::op_times public function * SassScript '*' operation. * 3
SassLiteral::op_xor public function * The SassScript xor operation. *
SassLiteral::toBoolean public function * Returns the boolean representation of the value of this *
SassLiteral::__get public function * Getter. *
SassLiteral::__toString public function