CWIS Developer Documentation
Static Public Member Functions | Protected Member Functions | Static Protected Member Functions | Protected Attributes | Static Protected Attributes | List of all members
JShrink\Minifier Class Reference

Static Public Member Functions

static minify ($js, $options=array())
 Takes a string containing javascript and removes unneeded characters in order to shrink the code without altering it's functionality. More...
 

Protected Member Functions

 minifyDirectToOutput ($js, $options)
 Processes a javascript string and outputs only the required characters, stripping out all unneeded characters. More...
 
 initialize ($js, $options)
 Initializes internal variables, normalizes new lines,. More...
 
 loop ()
 The primary action occurs here. More...
 
 clean ()
 Resets attributes that do not need to be stored between requests so that the next request is ready to go. More...
 
 getChar ()
 Returns the next string for processing based off of the current index. More...
 
 getReal ()
 This function gets the next "real" character. More...
 
 processOneLineComments ($startIndex)
 Removed one line comments, with the exception of some very specific types of conditional comments. More...
 
 processMultiLineComments ($startIndex)
 Skips multiline comments where appropriate, and includes them where needed. More...
 
 getNext ($string)
 Pushes the index ahead to the next instance of the supplied string. More...
 
 saveString ()
 When a javascript string is detected this function crawls for the end of it and saves the whole string. More...
 
 saveRegex ()
 When a regular expression is detected this function crawls for the end of it and saves the whole regex. More...
 
 lock ($js)
 Replace patterns in the given string and store the replacement. More...
 
 unlock ($js)
 Replace "locks" with the original characters. More...
 

Static Protected Member Functions

static isAlphaNumeric ($char)
 Checks to see if a character is alphanumeric. More...
 

Protected Attributes

 $input
 
 $index = 0
 
 $a = ''
 
 $b = ''
 
 $c
 
 $options
 
 $locks = array()
 

Static Protected Attributes

static $defaultOptions = array('flaggedComments' => true)
 

Detailed Description

Definition at line 32 of file Minifier.php.

Member Function Documentation

JShrink\Minifier::clean ( )
protected

Resets attributes that do not need to be stored between requests so that the next request is ready to go.

Another reason for this is to make sure the variables are cleared and are not taking up memory.

Definition at line 249 of file Minifier.php.

JShrink\Minifier::getChar ( )
protected

Returns the next string for processing based off of the current index.

Returns
string

Definition at line 263 of file Minifier.php.

JShrink\Minifier::getNext (   $string)
protected

Pushes the index ahead to the next instance of the supplied string.

If it is found the first character of the string is returned and the index is set to it's position.

Parameters
string$string
Returns
string|false Returns the first character of the string or false.

Definition at line 415 of file Minifier.php.

JShrink\Minifier::getReal ( )
protected

This function gets the next "real" character.

It is essentially a wrapper around the getChar function that skips comments. This has significant performance benefits as the skipping is done using native functions (ie, c code) rather than in script php.

Returns
string Next 'real' character to be processed.
Exceptions

Definition at line 302 of file Minifier.php.

JShrink\Minifier::initialize (   $js,
  $options 
)
protected

Initializes internal variables, normalizes new lines,.

Parameters
string$jsThe raw javascript to be minified
array$optionsVarious runtime options in an associative array

Definition at line 154 of file Minifier.php.

static JShrink\Minifier::isAlphaNumeric (   $char)
staticprotected

Checks to see if a character is alphanumeric.

Parameters
string$charJust one character
Returns
bool

Definition at line 538 of file Minifier.php.

JShrink\Minifier::lock (   $js)
protected

Replace patterns in the given string and store the replacement.

Parameters
string$jsThe string to lock
Returns
bool

Definition at line 549 of file Minifier.php.

JShrink\Minifier::loop ( )
protected

The primary action occurs here.

This function loops through the input string, outputting anything that's relevant and discarding anything that is not.

Definition at line 176 of file Minifier.php.

static JShrink\Minifier::minify (   $js,
  $options = array() 
)
static

Takes a string containing javascript and removes unneeded characters in order to shrink the code without altering it's functionality.

Parameters
string$jsThe raw javascript to be minified
array$optionsVarious runtime options in an associative array
Exceptions

Definition at line 103 of file Minifier.php.

JShrink\Minifier::minifyDirectToOutput (   $js,
  $options 
)
protected

Processes a javascript string and outputs only the required characters, stripping out all unneeded characters.

Parameters
string$jsThe raw javascript to be minified
array$optionsVarious runtime options in an associative array

Definition at line 141 of file Minifier.php.

JShrink\Minifier::processMultiLineComments (   $startIndex)
protected

Skips multiline comments where appropriate, and includes them where needed.

Conditional comments and "license" style blocks are preserved.

Parameters
int$startIndexThe index point where "getReal" function started
Returns
bool|string False if there's no character
Exceptions

Definition at line 359 of file Minifier.php.

JShrink\Minifier::processOneLineComments (   $startIndex)
protected

Removed one line comments, with the exception of some very specific types of conditional comments.

Parameters
int$startIndexThe index point where "getReal" function started
Returns
string

Definition at line 331 of file Minifier.php.

JShrink\Minifier::saveRegex ( )
protected

When a regular expression is detected this function crawls for the end of it and saves the whole regex.

Exceptions

Definition at line 511 of file Minifier.php.

JShrink\Minifier::saveString ( )
protected

When a javascript string is detected this function crawls for the end of it and saves the whole string.

Exceptions

Definition at line 438 of file Minifier.php.

JShrink\Minifier::unlock (   $js)
protected

Replace "locks" with the original characters.

Parameters
string$jsThe string to unlock
Returns
bool

Definition at line 574 of file Minifier.php.

Member Data Documentation

JShrink\Minifier::$a = ''
protected

Definition at line 54 of file Minifier.php.

JShrink\Minifier::$b = ''
protected

Definition at line 61 of file Minifier.php.

JShrink\Minifier::$c
protected

Definition at line 68 of file Minifier.php.

JShrink\Minifier::$defaultOptions = array('flaggedComments' => true)
staticprotected

Definition at line 84 of file Minifier.php.

JShrink\Minifier::$index = 0
protected

Definition at line 47 of file Minifier.php.

JShrink\Minifier::$input
protected

Definition at line 39 of file Minifier.php.

JShrink\Minifier::$locks = array()
protected

Definition at line 92 of file Minifier.php.

JShrink\Minifier::$options
protected

Definition at line 75 of file Minifier.php.


The documentation for this class was generated from the following file: