PHP Класс SassNumber

Provides operations and type testing for Sass numbers. Units are of the passed value are converted the those of the class value if it has units. e.g. 2cm + 20mm = 4cm while 2 + 20mm = 22mm.
Наследование: extends SassLiteral
Показать файл Открыть проект Примеры использования класса

Открытые свойства

Свойство Тип Описание
$inExpression whether this number is in an expression or a literal number Used to determine whether division should take place

Открытые методы

Метод Описание
__construct ( $value ) : SassNumber class constructor.
coerce ( array $numeratorUnits, array $denominatorUnits ) : SassNumber Returns the value of this number converted to other units.
getDenominatorUnits ( ) : string Returns the denominator units of this number.
getNumeratorUnits ( ) : string Returns the numerator units of this number.
getUnits ( ) : string Returns the units of this number.
getValue ( ) : float Returns the value of this number.
hasLegalUnits ( ) : boolean Returns a value indicating if this number has units that can be represented in CSS.
hasUnits ( ) : boolean Returns a value indicating if this number has units.
isComparableTo ( $other ) : boolean Returns a value indicating if this number can be compared to other.
isInt ( ) : boolean Returns a value indicating if this number is an integer.
isUnitless ( ) : boolean Returns a value indicating if this number is unitless.
isa ( string $subject ) : mixed Returns a value indicating if a token of this type can be matched at the start of the subject string.
length ( ) : integer Returns the number of values of SassNumber
nth ( $i ) : SassBoolean | SassNumber Returns the nth value of the SassNumber
op_div ( $other ) : mixed Divides this value by the value of other
op_eq ( $other ) : SassBoolean The SassScript == operation.
op_gt ( sassLiteral $other ) : SassBoolean The SassScript > operation.
op_gte ( sassLiteral $other ) : SassBoolean The SassScript >= operation.
op_lt ( sassLiteral $other ) : SassBoolean The SassScript < operation.
op_lte ( sassLiteral $other ) : SassBoolean The SassScript <= operation.
op_minus ( $other ) : mixed Subtracts the value of other from this value
op_modulo ( string $other ) : mixed Takes the modulus (remainder) of this value divided by the value of other
op_plus ( $other ) : mixed Adds the value of other to the value of this
op_times ( $other ) : mixed Multiplies this value by the value of other
op_unary_concat ( )
op_unary_minus ( ) : SassNumber Unary - operator
op_unary_plus ( ) : SassNumber Unary + operator
toInt ( ) : integer Returns the integer value.
toString ( ) : string Converts the number to a string with it's units if any.
unitString ( $numeratorUnits, $denominatorUnits ) : string Returns a string representation of the units.

Приватные методы

Метод Описание
areConvertable ( array $units ) : boolean Returns a value indicating if all the units are capable of being converted
coercionFactor ( array $fromUnits, array $toUnits ) : float Calculates the corecion factor to apply to the value
convert ( SassNumber $other ) : SassNumber Converts values and units.
removeCommonUnits ( array $u1, array $u2 ) : array Removes common units from each set.

Описание методов

__construct() публичный Метод

Sets the value and units of the number.
public __construct ( $value ) : SassNumber
Результат SassNumber

coerce() публичный Метод

The conversion takes into account the relationship between e.g. mm and cm, as well as between e.g. in and cm. If this number is unitless, it will simply return itself with the given units.
public coerce ( array $numeratorUnits, array $denominatorUnits ) : SassNumber
$numeratorUnits array
$denominatorUnits array
Результат SassNumber

getDenominatorUnits() публичный Метод

Returns the denominator units of this number.
public getDenominatorUnits ( ) : string
Результат string the denominator units of this number

getNumeratorUnits() публичный Метод

Returns the numerator units of this number.
public getNumeratorUnits ( ) : string
Результат string the numerator units of this number

getUnits() публичный Метод

Returns the units of this number.
public getUnits ( ) : string
Результат string the units of this number

getValue() публичный Метод

Returns the value of this number.
public getValue ( ) : float
Результат float the value of this number.

hasLegalUnits() публичный Метод

Returns a value indicating if this number has units that can be represented in CSS.
public hasLegalUnits ( ) : boolean
Результат boolean true if this number has units that can be represented in CSS, false if not

hasUnits() публичный Метод

Returns a value indicating if this number has units.
public hasUnits ( ) : boolean
Результат boolean true if this number has, false if not

isComparableTo() публичный Метод

Returns a value indicating if this number can be compared to other.
public isComparableTo ( $other ) : boolean
Результат boolean true if this number can be compared to other, false if not

isInt() публичный Метод

Returns a value indicating if this number is an integer.
public isInt ( ) : boolean
Результат boolean true if this number is an integer, false if not

isUnitless() публичный Метод

Returns a value indicating if this number is unitless.
public isUnitless ( ) : boolean
Результат boolean true if this number is unitless, false if not

isa() публичный статический Метод

Returns a value indicating if a token of this type can be matched at the start of the subject string.
public static isa ( string $subject ) : mixed
$subject string the subject string
Результат mixed match at the start of the string or false if no match

length() публичный Метод

Returns the number of values of SassNumber
public length ( ) : integer
Результат integer

nth() публичный Метод

Returns the nth value of the SassNumber
public nth ( $i ) : SassBoolean | SassNumber
Результат SassBoolean | SassNumber

op_div() публичный Метод

Divides this value by the value of other
public op_div ( $other ) : mixed
Результат mixed SassNumber if other is a SassNumber or SassColour if it is a SassColour

op_eq() публичный Метод

The SassScript == operation.
public op_eq ( $other ) : SassBoolean
Результат SassBoolean SassBoolean object with the value true if the values of this and other are equal, false if they are not

op_gt() публичный Метод

The SassScript > operation.
public op_gt ( sassLiteral $other ) : SassBoolean
$other sassLiteral the value to compare to this
Результат SassBoolean SassBoolean object with the value true if the values of this is greater than the value of other, false if it is not

op_gte() публичный Метод

The SassScript >= operation.
public op_gte ( sassLiteral $other ) : SassBoolean
$other sassLiteral the value to compare to this
Результат SassBoolean SassBoolean object with the value true if the values of this is greater than or equal to the value of other, false if it is not

op_lt() публичный Метод

The SassScript < operation.
public op_lt ( sassLiteral $other ) : SassBoolean
$other sassLiteral the value to compare to this
Результат SassBoolean SassBoolean object with the value true if the values of this is less than the value of other, false if it is not

op_lte() публичный Метод

The SassScript <= operation.
public op_lte ( sassLiteral $other ) : SassBoolean
$other sassLiteral the value to compare to this
Результат SassBoolean SassBoolean object with the value true if the values of this is less than or equal to the value of other, false if it is not

op_minus() публичный Метод

Subtracts the value of other from this value
public op_minus ( $other ) : mixed
Результат mixed SassNumber if other is a SassNumber or SassColour if it is a SassColour

op_modulo() публичный Метод

Takes the modulus (remainder) of this value divided by the value of other
public op_modulo ( string $other ) : mixed
$other string value to divide by
Результат mixed SassNumber if other is a SassNumber or SassColour if it is a SassColour

op_plus() публичный Метод

Adds the value of other to the value of this
public op_plus ( $other ) : mixed
Результат mixed SassNumber if other is a SassNumber or SassColour if it is a SassColour

op_times() публичный Метод

Multiplies this value by the value of other
public op_times ( $other ) : mixed
Результат mixed SassNumber if other is a SassNumber or SassColour if it is a SassColour

op_unary_concat() публичный Метод

public op_unary_concat ( )

op_unary_minus() публичный Метод

Unary - operator
public op_unary_minus ( ) : SassNumber
Результат SassNumber the negative value of this number

op_unary_plus() публичный Метод

Unary + operator
public op_unary_plus ( ) : SassNumber
Результат SassNumber the value of this number

toInt() публичный Метод

Returns the integer value.
public toInt ( ) : integer
Результат integer the integer value.

toString() публичный Метод

If the units are px the result is rounded down to the nearest integer, otherwise the result is rounded to the specified precision.
public toString ( ) : string
Результат string number as a string with it's units if any

unitString() публичный Метод

Returns a string representation of the units.
public unitString ( $numeratorUnits, $denominatorUnits ) : string
Результат string the units

Описание свойств

$inExpression публичное свойство

whether this number is in an expression or a literal number Used to determine whether division should take place
public $inExpression