PHP Class 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.
Inheritance: extends SassLiteral
Afficher le fichier Open project: richthegeek/phpsass Class Usage Examples

Méthodes publiques

Свойство Type Description
$inExpression whether this number is in an expression or a literal number Used to determine whether division should take place

Méthodes publiques

Méthode Description
__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.

Private Methods

Méthode Description
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.

Method Details

__construct() public méthode

Sets the value and units of the number.
public __construct ( $value ) : SassNumber
Résultat SassNumber

coerce() public méthode

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
Résultat SassNumber

getDenominatorUnits() public méthode

Returns the denominator units of this number.
public getDenominatorUnits ( ) : string
Résultat string the denominator units of this number

getNumeratorUnits() public méthode

Returns the numerator units of this number.
public getNumeratorUnits ( ) : string
Résultat string the numerator units of this number

getUnits() public méthode

Returns the units of this number.
public getUnits ( ) : string
Résultat string the units of this number

getValue() public méthode

Returns the value of this number.
public getValue ( ) : float
Résultat float the value of this number.

hasLegalUnits() public méthode

Returns a value indicating if this number has units that can be represented in CSS.
public hasLegalUnits ( ) : boolean
Résultat boolean true if this number has units that can be represented in CSS, false if not

hasUnits() public méthode

Returns a value indicating if this number has units.
public hasUnits ( ) : boolean
Résultat boolean true if this number has, false if not

isComparableTo() public méthode

Returns a value indicating if this number can be compared to other.
public isComparableTo ( $other ) : boolean
Résultat boolean true if this number can be compared to other, false if not

isInt() public méthode

Returns a value indicating if this number is an integer.
public isInt ( ) : boolean
Résultat boolean true if this number is an integer, false if not

isUnitless() public méthode

Returns a value indicating if this number is unitless.
public isUnitless ( ) : boolean
Résultat boolean true if this number is unitless, false if not

isa() public static méthode

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
Résultat mixed match at the start of the string or false if no match

length() public méthode

Returns the number of values of SassNumber
public length ( ) : integer
Résultat integer

nth() public méthode

Returns the nth value of the SassNumber
public nth ( $i ) : SassBoolean | SassNumber
Résultat SassBoolean | SassNumber

op_div() public méthode

Divides this value by the value of other
public op_div ( $other ) : mixed
Résultat mixed SassNumber if other is a SassNumber or SassColour if it is a SassColour

op_eq() public méthode

The SassScript == operation.
public op_eq ( $other ) : SassBoolean
Résultat SassBoolean SassBoolean object with the value true if the values of this and other are equal, false if they are not

op_gt() public méthode

The SassScript > operation.
public op_gt ( sassLiteral $other ) : SassBoolean
$other sassLiteral the value to compare to this
Résultat 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() public méthode

The SassScript >= operation.
public op_gte ( sassLiteral $other ) : SassBoolean
$other sassLiteral the value to compare to this
Résultat 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() public méthode

The SassScript < operation.
public op_lt ( sassLiteral $other ) : SassBoolean
$other sassLiteral the value to compare to this
Résultat 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() public méthode

The SassScript <= operation.
public op_lte ( sassLiteral $other ) : SassBoolean
$other sassLiteral the value to compare to this
Résultat 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() public méthode

Subtracts the value of other from this value
public op_minus ( $other ) : mixed
Résultat mixed SassNumber if other is a SassNumber or SassColour if it is a SassColour

op_modulo() public méthode

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
Résultat mixed SassNumber if other is a SassNumber or SassColour if it is a SassColour

op_plus() public méthode

Adds the value of other to the value of this
public op_plus ( $other ) : mixed
Résultat mixed SassNumber if other is a SassNumber or SassColour if it is a SassColour

op_times() public méthode

Multiplies this value by the value of other
public op_times ( $other ) : mixed
Résultat mixed SassNumber if other is a SassNumber or SassColour if it is a SassColour

op_unary_concat() public méthode

public op_unary_concat ( )

op_unary_minus() public méthode

Unary - operator
public op_unary_minus ( ) : SassNumber
Résultat SassNumber the negative value of this number

op_unary_plus() public méthode

Unary + operator
public op_unary_plus ( ) : SassNumber
Résultat SassNumber the value of this number

toInt() public méthode

Returns the integer value.
public toInt ( ) : integer
Résultat integer the integer value.

toString() public méthode

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
Résultat string number as a string with it's units if any

unitString() public méthode

Returns a string representation of the units.
public unitString ( $numeratorUnits, $denominatorUnits ) : string
Résultat string the units

Property Details

$inExpression public_oe property

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