class Number in SCSS Compiler 1.0.x
Same name in this branch
- 1.0.x src/Type/Number.php \Drupal\compiler_scss\Type\Number
- 1.0.x src/Config/Schema/Number.php \Drupal\compiler_scss\Config\Schema\Number
- 1.0.x src/Plugin/DataType/Number.php \Drupal\compiler_scss\Plugin\DataType\Number
Defines a Sass number type optionally paired with a unit.
Copyright (C) 2021 Library Solutions, LLC (et al.).
This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.
Hierarchy
- class \Drupal\compiler_scss\Type\Number
Expanded class hierarchy of Number
3 files declare their use of Number
- Number.php in src/
Config/ Schema/ Number.php - Number.php in src/
Plugin/ DataType/ Number.php - ScssNumber.php in src/
Element/ ScssNumber.php
File
- src/
Type/ Number.php, line 15
Namespace
Drupal\compiler_scss\TypeView source
class Number {
/**
* The magnitude of the number.
*
* @var float
*/
protected $value = 0.0;
/**
* The unit of the number.
*
* @var string|null
*/
protected $unit = NULL;
/**
* Constructs a Number object.
*
* @param float $value
* The magnitude of the number.
* @param string|null $unit
* The unit of the number. Must be supported by the underlying compiler.
*/
public function __construct(float $value, ?string $unit = NULL) {
if (isset($unit) && !is_string($unit)) {
throw new \RuntimeException('$unit must be a string or NULL');
}
$this->value = $value;
$this->unit = $unit;
}
/**
* Get the unit for this number.
*
* @return string|null
* The unit for this number.
*/
public function unit() : ?string {
return $this->unit;
}
/**
* Get the magnitude of this number.
*
* @return float
* The magnitude of this number.
*/
public function value() : float {
return $this->value;
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
Number:: |
protected | property | The unit of the number. | |
Number:: |
protected | property | The magnitude of the number. | |
Number:: |
public | function | Get the unit for this number. | |
Number:: |
public | function | Get the magnitude of this number. | |
Number:: |
public | function | Constructs a Number object. |