You are here

private function CSSmin::strSlice in Advanced CSS/JS Aggregation 7.2

PHP port of Javascript's "slice" function for strings only Author: Tubal Martin

Parameters

string $str:

int $start index:

int|bool $end index (optional):

Return value

string

5 calls to CSSmin::strSlice()
CSSmin::minify in advagg_css_compress/yui/CSSMin.inc
Minifies the given input CSS string
CSSmin::processDataUrls in advagg_css_compress/yui/CSSMin.inc
Searches & replaces all data urls with tokens before we start compressing, to avoid performance issues running some of the subsequent regexes against large string chunks.
CSSmin::processStrings in advagg_css_compress/yui/CSSMin.inc
CSSmin::run in advagg_css_compress/yui/CSSMin.inc
Minifies a string of CSS
CSSmin::shortenHexColors in advagg_css_compress/yui/CSSMin.inc
Compresses HEX color values of the form #AABBCC to #ABC or short color name.

File

advagg_css_compress/yui/CSSMin.inc, line 1238

Class

CSSmin

Code

private function strSlice($str, $start = 0, $end = false) {
  if ($end !== false && ($start < 0 || $end <= 0)) {
    $max = strlen($str);
    if ($start < 0) {
      if (($start = $max + $start) < 0) {
        return '';
      }
    }
    if ($end < 0) {
      if (($end = $max + $end) < 0) {
        return '';
      }
    }
    if ($end <= $start) {
      return '';
    }
  }
  $slice = $end === false ? substr($str, $start) : substr($str, $start, $end - $start);
  return $slice === false ? '' : $slice;
}