\csstidy_optimise

CSS Optimising Class

This class optimises CSS data generated by csstidy.

Summary

Methods
Properties
Constants
csstidy_optimise()
postparse()
value()
shorthands()
subvalue()
shorthand()
compress_important()
cut_color()
compress_numbers()
AnalyseCssNumber()
merge_selectors()
discard_invalid_selectors()
dissolve_4value_shorthands()
explode_ws()
merge_4value_shorthands()
dissolve_short_bg()
merge_bg()
dissolve_short_font()
merge_font()
No public properties found
No constants found
No protected methods found
No protected properties found
N/A
No private methods found
No private properties found
N/A

Methods

csstidy_optimise()

csstidy_optimise(array $css)

Constructor

Parameters

array $css

contains the class csstidy

postparse()

postparse()

Optimises $css after parsing

value()

value()

Optimises values

shorthands()

shorthands()

Optimises shorthands

subvalue()

subvalue()

Optimises a sub-value

shorthand()

shorthand(string $value) : string

Compresses shorthand values. Example: margin:1px 1px 1px 1px -> margin:1px

Parameters

string $value

Returns

string

compress_important()

compress_important(string $string) : string

Removes unnecessary whitespace in ! important

Parameters

string $string

Returns

string

cut_color()

cut_color(string $color) : string

Color compression function. Converts all rgb() values to #-values and uses the short-form if possible. Also replaces 4 color names by #-values.

Parameters

string $color

Returns

string

compress_numbers()

compress_numbers(string $subvalue) : string

Compresses numbers (ie. 1.0 becomes 1 or 1.100 becomes 1.1 )

Parameters

string $subvalue

Returns

string

AnalyseCssNumber()

AnalyseCssNumber(string $string) : array

Checks if a given string is a CSS valid number. If it is, an array containing the value and unit is returned

Parameters

string $string

Returns

array —

('unit' if unit is found or '' if no unit exists, number value) or false if no number

merge_selectors()

merge_selectors(array $array) : array

Merges selectors with same properties. Example: a{color:red} b{color:red} -> a,b{color:red} Very basic and has at least one bug. Hopefully there is a replacement soon.

Parameters

array $array

Returns

array

discard_invalid_selectors()

discard_invalid_selectors( $array)

Removes invalid selectors and their corresponding rule-sets as defined by 4.1.7 in REC-CSS2. This is a very rudimentary check and should be replaced by a full-blown parsing algorithm or regular expression

Parameters

$array

dissolve_4value_shorthands()

dissolve_4value_shorthands(string $property, string $value) : array

Dissolves properties like padding:10px 10px 10px to padding-top:10px;padding-bottom:10px;.

..

Parameters

string $property
string $value

Returns

array

explode_ws()

explode_ws(string $sep, string $string) : array

Explodes a string as explode() does, however, not if $sep is escaped or within a string.

Parameters

string $sep

seperator

string $string

Returns

array

merge_4value_shorthands()

merge_4value_shorthands(array $array) : array

Merges Shorthand properties again, the opposite of dissolve_4value_shorthands()

Parameters

array $array

Returns

array

dissolve_short_bg()

dissolve_short_bg(string $str_value) : array

Dissolve background property

Parameters

string $str_value

Returns

array

merge_bg()

merge_bg(array $input_css) : array

Merges all background properties

Parameters

array $input_css

Returns

array

dissolve_short_font()

dissolve_short_font(string $str_value) : array

Dissolve font property

Parameters

string $str_value

Returns

array

merge_font()

merge_font(array $input_css) : array

Merges all fonts properties

Parameters

array $input_css

Returns

array