Overview

Namespaces

  • MatthiasMullie
    • Minify
      • Exceptions
    • PathConverter
  • None
  • ReCaptcha
    • RequestMethod
  • TOTP

Classes

  • CSS
  • JS
  • Minify

Exceptions

  • Exception
  • Overview
  • Namespace
  • Class

Class CSS

CSS minifier.

Please report bugs on https://github.com/matthiasmullie/minify/issues

MatthiasMullie\Minify\Minify
Extended by MatthiasMullie\Minify\CSS
Namespace: MatthiasMullie\Minify
Copyright: Copyright (c) 2012, Matthias Mullie. All rights reserved
License: License
Author: Matthias Mullie minify@mullie.eu
Author: Tijs Verkoyen minify@verkoyen.eu
Located at Sources/minify/src/CSS.php
Methods summary
public
# setMaxImportSize( integer $size )

Set the maximum size if files to be imported.

Set the maximum size if files to be imported.

Files larger than this size (in kB) will not be imported into the CSS. Importing files into the CSS as data-uri will save you some connections, but we should only import relatively small decorative images so that our CSS file doesn't get too bulky.

Parameters

$size
Size in kB
public
# setImportExtensions( array $extensions )

Set the type of extensions to be imported into the CSS (to save network connections). Keys of the array should be the file extensions & respective values should be the data type.

Set the type of extensions to be imported into the CSS (to save network connections). Keys of the array should be the file extensions & respective values should be the data type.

Parameters

$extensions
Array of file extensions
protected string
# moveImportsToTop( string $content )

Move any import statements to the top.

Move any import statements to the top.

Parameters

$content
Nearly finished CSS content

Returns

string
protected string
# combineImports( string $source, string $content, string[] $parents )

Combine CSS from import statements.

Combine CSS from import statements.

Parameters

$source
The file to combine imports for
$content
The CSS content to combine imports for
$parents
Parent paths, for circular reference checks

Returns

string

Throws

MatthiasMullie\Minify\Exceptions\FileImportException

Import's

will be loaded and their content merged into the original file, to save HTTP requests.


protected string
# importFiles( string $source, string $content )

Import files into the CSS, base64-ized.

Import files into the CSS, base64-ized.

Parameters

$source
The file to import files for
$content
The CSS content to import files for

Returns

string

Url(image.jpg)

images will be loaded and their content merged into the original file, to save HTTP requests.


public string
# execute( string[optional] $path = null, string[] $parents = array() )

Minify the data. Perform CSS optimizations.

Minify the data. Perform CSS optimizations.

Parameters

$path
Path to write the data to
$parents
Parent paths, for circular reference checks

Returns

string
The minified data
protected string
# move( MatthiasMullie\PathConverter\Converter $converter, string $content )

Moving a css file should update all relative urls. Relative references (e.g. ../images/image.gif) in a certain css file, will have to be updated when a file is being saved at another location (e.g. ../../images/image.gif, if the new CSS file is 1 folder deeper).

Moving a css file should update all relative urls. Relative references (e.g. ../images/image.gif) in a certain css file, will have to be updated when a file is being saved at another location (e.g. ../../images/image.gif, if the new CSS file is 1 folder deeper).

Parameters

$converter
Relative path converter
$content
The CSS content to update relative urls for

Returns

string
protected string
# shortenHex( string $content )

Shorthand hex color codes.

FF0000 -> #F00.

Shorthand hex color codes.

FF0000 -> #F00.

Parameters

$content
The CSS content to shorten the hex color codes for

Returns

string
protected string
# shortenFontWeights( string $content )

Shorten CSS font weights.

Shorten CSS font weights.

Parameters

$content
The CSS content to shorten the font weights for

Returns

string
protected string
# shortenZeroes( string $content )

Shorthand 0 values to plain 0, instead of e.g. -0em.

Shorthand 0 values to plain 0, instead of e.g. -0em.

Parameters

$content
The CSS content to shorten the zero values for

Returns

string
protected string
# stripEmptyTags( string $content )

Strip comments from source code.

Strip comments from source code.

Parameters

$content

Returns

string
protected
# stripComments( )

Strip comments from source code.

Strip comments from source code.

protected string
# stripWhitespace( string $content )

Strip whitespace.

Strip whitespace.

Parameters

$content
The CSS content to strip the whitespace for

Returns

string
protected boolean
# canImportBySize( string $path )

Check if file is small enough to be imported.

Check if file is small enough to be imported.

Parameters

$path
The path to the file

Returns

boolean
Methods inherited from MatthiasMullie\Minify\Minify
__construct(), add(), cache(), canImportFile(), extractStrings(), gzip(), load(), minify(), openFileForWriting(), registerPattern(), replace(), replacePattern(), restoreExtractedData(), save(), writeToFile()
Properties summary
protected integer $maxImportSize
# 5
protected string[] $importExtensions
# array( 'gif' => 'data:image/gif', 'png' => 'data:image/png', 'jpe' => 'data:image/jpeg', 'jpg' => 'data:image/jpeg', 'jpeg' => 'data:image/jpeg', 'svg' => 'data:image/svg+xml', 'woff' => 'data:application/x-font-woff', 'tif' => 'image/tiff', 'tiff' => 'image/tiff', 'xbm' => 'image/x-xbitmap', )
Properties inherited from MatthiasMullie\Minify\Minify
$data, $extracted, $patterns
API documentation generated by ApiGen