csstidy_optimise
in package
CSS Optimising Class
This class optimises CSS data generated by csstidy.
Tags
Table of Contents
Properties
- $at : mixed
- $css : mixed
- $parser : object
- csstidy object
- $property : mixed
- $selector : mixed
- $sub_value : mixed
- $value : mixed
Methods
- __construct() : mixed
- Constructor
- AnalyseCssNumber() : array<string|int, mixed>|false
- Checks if a given string is a CSS valid number. If it is, an array containing the value and unit is returned
- compress_important() : string
- Removes unnecessary whitespace in ! important
- compress_numbers() : string
- Compresses numbers (ie. 1.0 becomes 1 or 1.100 becomes 1.1 )
- cut_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.
- discard_invalid_selectors() : mixed
- 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
- dissolve_4value_radius_shorthands() : array<string|int, mixed>
- Dissolves radius properties like border-radius:10px 10px 10px / 1px 2px to border-top-left:10px 1px;border-top-right:10px 2x;.
- dissolve_4value_shorthands() : array<string|int, mixed>
- Dissolves properties like padding:10px 10px 10px to padding-top:10px;padding-bottom:10px;.
- dissolve_short_bg() : array<string|int, mixed>
- Dissolve background property
- dissolve_short_font() : array<string|int, mixed>
- Dissolve font property
- explode_ws() : array<string|int, mixed>
- Explodes a string as explode() does, however, not if $sep is escaped or within a string.
- merge_4value_radius_shorthands() : array<string|int, mixed>
- Merges Shorthand properties again, the opposite of dissolve_4value_shorthands()
- merge_4value_shorthands() : array<string|int, mixed>
- Merges Shorthand properties again, the opposite of dissolve_4value_shorthands()
- merge_bg() : array<string|int, mixed>
- Merges all background properties
- merge_font() : array<string|int, mixed>
- Merges all fonts properties
- merge_selectors() : void
- 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.
- postparse() : mixed
- Optimises $css after parsing
- reverse_left_and_right() : array<string|int, mixed>
- Reverse left vs right in a list of properties/values
- reverse_left_and_right_4value_radius_shorthands() : string
- Reversing 4 values radius shorthands properties
- reverse_left_and_right_4value_shorthands() : string
- Reversing 4 values shorthands properties
- reverse_left_and_right__moz_border_radius() : string
- Reversing border-radius shorthands
- reverse_left_and_right__webkit_border_radius() : string
- Reversing border-radius shorthands
- reverse_left_and_right_background() : string
- Reversing background shorthands
- reverse_left_and_right_background_position() : string
- Reversing background position shorthands
- reverse_left_and_right_background_position_x() : string
- Reversing background position shorthands
- reverse_left_and_right_border_color() : string
- Reversing border-color shorthands
- reverse_left_and_right_border_radius() : string
- Reversing border-radius shorthands
- reverse_left_and_right_border_style() : string
- Reversing border-style shorthands
- reverse_left_and_right_border_width() : string
- Reversing border-width shorthands
- reverse_left_and_right_margin() : string
- Reversing margin shorthands
- reverse_left_and_right_padding() : string
- Reversing padding shorthands
- shorthand() : string
- Compresses shorthand values. Example: margin:1px 1px 1px 1px -> margin:1px
- shorthands() : mixed
- Optimises shorthands
- subvalue() : mixed
- Optimises a sub-value
- value() : mixed
- Optimises values
Properties
$at
public
mixed
$at
$css
public
mixed
$css
$parser
csstidy object
public
object
$parser
$property
public
mixed
$property
$selector
public
mixed
$selector
$sub_value
public
mixed
$sub_value
$value
public
mixed
$value
Methods
__construct()
Constructor
public
__construct(csstidy $css) : mixed
Parameters
- $css : csstidy
-
contains the class csstidy
Tags
AnalyseCssNumber()
Checks if a given string is a CSS valid number. If it is, an array containing the value and unit is returned
public
AnalyseCssNumber(string $string) : array<string|int, mixed>|false
Parameters
- $string : string
Return values
array<string|int, mixed>|false —('unit' if unit is found or '' if no unit exists, number value) or false if no number
compress_important()
Removes unnecessary whitespace in ! important
public
compress_important(string &$string) : string
Parameters
- $string : string
Tags
Return values
stringcompress_numbers()
Compresses numbers (ie. 1.0 becomes 1 or 1.100 becomes 1.1 )
public
compress_numbers(string $subvalue) : string
Parameters
- $subvalue : string
Tags
Return values
stringcut_color()
Color compression function. Converts all rgb() values to #-values and uses the short-form if possible. Also replaces 4 color names by #-values.
public
cut_color(string $color) : string
Parameters
- $color : string
Tags
Return values
stringdiscard_invalid_selectors()
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
public
discard_invalid_selectors(mixed &$array) : mixed
Parameters
- $array : mixed
Tags
dissolve_4value_radius_shorthands()
Dissolves radius properties like border-radius:10px 10px 10px / 1px 2px to border-top-left:10px 1px;border-top-right:10px 2x;.
public
dissolve_4value_radius_shorthands(string $property, string $value) : array<string|int, mixed>
..
Parameters
- $property : string
- $value : string
Tags
Return values
array<string|int, mixed>dissolve_4value_shorthands()
Dissolves properties like padding:10px 10px 10px to padding-top:10px;padding-bottom:10px;.
public
dissolve_4value_shorthands(string $property, string $value[, array<string|int, mixed>|null $shorthands = null ]) : array<string|int, mixed>
..
Parameters
- $property : string
- $value : string
- $shorthands : array<string|int, mixed>|null = null
Tags
Return values
array<string|int, mixed>dissolve_short_bg()
Dissolve background property
public
dissolve_short_bg(string $str_value) : array<string|int, mixed>
Parameters
- $str_value : string
Tags
Return values
array<string|int, mixed>dissolve_short_font()
Dissolve font property
public
dissolve_short_font(string $str_value) : array<string|int, mixed>
Parameters
- $str_value : string
Tags
Return values
array<string|int, mixed>explode_ws()
Explodes a string as explode() does, however, not if $sep is escaped or within a string.
public
explode_ws(string $sep, string $string[, bool $explode_in_parenthesis = false ]) : array<string|int, mixed>
Parameters
- $sep : string
-
seperator
- $string : string
- $explode_in_parenthesis : bool = false
Tags
Return values
array<string|int, mixed>merge_4value_radius_shorthands()
Merges Shorthand properties again, the opposite of dissolve_4value_shorthands()
public
merge_4value_radius_shorthands(array<string|int, mixed> $array) : array<string|int, mixed>
Parameters
- $array : array<string|int, mixed>
Tags
Return values
array<string|int, mixed>merge_4value_shorthands()
Merges Shorthand properties again, the opposite of dissolve_4value_shorthands()
public
merge_4value_shorthands(array<string|int, mixed> $array[, array<string|int, mixed>|null $shorthands = null ]) : array<string|int, mixed>
Parameters
- $array : array<string|int, mixed>
- $shorthands : array<string|int, mixed>|null = null
Tags
Return values
array<string|int, mixed>merge_bg()
Merges all background properties
public
merge_bg(array<string|int, mixed> $input_css) : array<string|int, mixed>
Parameters
- $input_css : array<string|int, mixed>
Tags
Return values
array<string|int, mixed>merge_font()
Merges all fonts properties
public
merge_font(array<string|int, mixed> $input_css) : array<string|int, mixed>
Parameters
- $input_css : array<string|int, mixed>
Tags
Return values
array<string|int, mixed>merge_selectors()
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.
public
merge_selectors(array<string|int, mixed> &$array) : void
Parameters
- $array : array<string|int, mixed>
Tags
postparse()
Optimises $css after parsing
public
postparse() : mixed
Tags
reverse_left_and_right()
Reverse left vs right in a list of properties/values
public
reverse_left_and_right(array<string|int, mixed> $array) : array<string|int, mixed>
Parameters
- $array : array<string|int, mixed>
Return values
array<string|int, mixed>reverse_left_and_right_4value_radius_shorthands()
Reversing 4 values radius shorthands properties
public
reverse_left_and_right_4value_radius_shorthands(mixed $property, string $value) : string
Parameters
- $property : mixed
- $value : string
Return values
stringreverse_left_and_right_4value_shorthands()
Reversing 4 values shorthands properties
public
reverse_left_and_right_4value_shorthands(mixed $property, string $value) : string
Parameters
- $property : mixed
- $value : string
Return values
stringreverse_left_and_right__moz_border_radius()
Reversing border-radius shorthands
public
reverse_left_and_right__moz_border_radius(string $value) : string
Parameters
- $value : string
Return values
stringreverse_left_and_right__webkit_border_radius()
Reversing border-radius shorthands
public
reverse_left_and_right__webkit_border_radius(string $value) : string
Parameters
- $value : string
Return values
stringreverse_left_and_right_background()
Reversing background shorthands
public
reverse_left_and_right_background(string $value) : string
Parameters
- $value : string
Return values
stringreverse_left_and_right_background_position()
Reversing background position shorthands
public
reverse_left_and_right_background_position(string $value) : string
Parameters
- $value : string
Return values
stringreverse_left_and_right_background_position_x()
Reversing background position shorthands
public
reverse_left_and_right_background_position_x(string $value) : string
Parameters
- $value : string
Return values
stringreverse_left_and_right_border_color()
Reversing border-color shorthands
public
reverse_left_and_right_border_color(string $value) : string
Parameters
- $value : string
Return values
stringreverse_left_and_right_border_radius()
Reversing border-radius shorthands
public
reverse_left_and_right_border_radius(string $value) : string
Parameters
- $value : string
Return values
stringreverse_left_and_right_border_style()
Reversing border-style shorthands
public
reverse_left_and_right_border_style(string $value) : string
Parameters
- $value : string
Return values
stringreverse_left_and_right_border_width()
Reversing border-width shorthands
public
reverse_left_and_right_border_width(string $value) : string
Parameters
- $value : string
Return values
stringreverse_left_and_right_margin()
Reversing margin shorthands
public
reverse_left_and_right_margin(string $value) : string
Parameters
- $value : string
Return values
stringreverse_left_and_right_padding()
Reversing padding shorthands
public
reverse_left_and_right_padding(string $value) : string
Parameters
- $value : string
Return values
stringshorthand()
Compresses shorthand values. Example: margin:1px 1px 1px 1px -> margin:1px
public
shorthand(string $value) : string
Parameters
- $value : string
Tags
Return values
stringshorthands()
Optimises shorthands
public
shorthands() : mixed
Tags
subvalue()
Optimises a sub-value
public
subvalue() : mixed
Tags
value()
Optimises values
public
value() : mixed