Skip to content
Browse files

Cleaned up a few vars to match CI coding standards.

  • Loading branch information...
1 parent 422fe99 commit 84f19af523331564c3ae5b5127da537c8b4f18e3 @ericbarnes committed Apr 22, 2011
Showing with 45 additions and 45 deletions.
  1. +23 −22 libraries/Minify/Minify.php
  2. +15 −16 libraries/Minify/drivers/Minify_css.php
  3. +3 −3 libraries/Minify/drivers/Minify_js.php
  4. +4 −4 readme.md
View
45 libraries/Minify/Minify.php
@@ -53,19 +53,19 @@ public function __construct($params = array())
* @author Eric Barnes, F.S.Encinas
* @param array $files
* @param string $type
- * @param string $cssCharset
* @param bool $compact
- * @return void
+ * @param string $css_charset
+ * @return mixed
*/
- public function combine_files($files = array(), $type = '', $compact = TRUE, $cssCharset = 'utf-8')
+ public function combine_files($files = array(), $type = '', $compact = TRUE, $css_charset = 'utf-8')
{
- if ( !is_array($files) OR count($files) < 1)
+ if ( ! is_array($files) OR count($files) < 1)
{
log_message('error', 'Minify->combine_files missing files array');
return FALSE;
}
- return $this->_do_combine($files, $type, $compact, $cssCharset);
+ return $this->_do_combine($files, $type, $compact, $css_charset);
}
// ------------------------------------------------------------------------
@@ -78,11 +78,11 @@ public function combine_files($files = array(), $type = '', $compact = TRUE, $cs
* @param string $directory
* @param array $ignore
* @param string $type
- * @param string $cssCharset
* @param bool $compact
+ * @param string $css_charset
* @return string
*/
- public function combine_directory($directory = '', $ignore = array(), $type = '', $compact = TRUE, $cssCharset = 'utf-8')
+ public function combine_directory($directory = '', $ignore = array(), $type = '', $compact = TRUE, $css_charset = 'utf-8')
{
$available = array();
@@ -113,7 +113,7 @@ public function combine_directory($directory = '', $ignore = array(), $type = ''
}
}
- return $this->_do_combine($available, $type, $compact, $cssCharset);
+ return $this->_do_combine($available, $type, $compact, $css_charset);
}
// ------------------------------------------------------------------------
@@ -126,47 +126,48 @@ public function combine_directory($directory = '', $ignore = array(), $type = ''
* @author Eric Barnes, F.S.Encinas
* @param array $files
* @param string $type
- * @param string $cssCharset
* @param bool $compact
+ * @param string $css_charset
* @return string
*/
- private function _do_combine($files, $type, $compact = TRUE, $cssCharset = 'utf-8')
+ private function _do_combine($files, $type, $compact = TRUE, $css_charset = 'utf-8')
{
$contents = '';
- $fileCount = 0;
+ $file_count = 0;
foreach ($files AS $file)
{
- if ( !file_exists($file))
+ if ( ! file_exists($file))
{
- log_message('error', 'Minify->_do_combine missing file ' . $file);
+ log_message('error', 'Minify->_do_combine missing file '.$file);
continue;
}
- $fileCount++;
+ $file_count++;
if ($type == '')
{
$type = $this->_get_type($file);
}
- $pathInf = pathinfo($file, PATHINFO_BASENAME); // Referal File and path
+ $path_info = pathinfo($file, PATHINFO_BASENAME); // Referal File and path
if ($type == 'css')
{
// only one charset placed at the beginning of the document is allowed
// in order to keep standars compliance and fixing Webkit problems
// Note: Minify_css driver yet remove all charsets previously
- if ($fileCount == 1) {
- $contents .= '@charset "'. $cssCharset .'";' . "\n";
+ if ($file_count == 1)
+ {
+ $contents .= '@charset "'.$css_charset.'";'."\n";
}
- $contents .= "\n" . '/* @fileRef ' . $pathInf . ' */' . "\n";
- $contents .= $this->css->min($file, $compact, $isaggregated = TRUE);
+ $contents .= "\n".'/* @fileRef '.$path_info.' */'."\n";
+ $contents .= $this->css->min($file, $compact, $is_aggregated = TRUE);
}
elseif ($type == 'js')
{
- unset($cssCharset);
- $contents .= "\n" . '// @fileRef ' . $pathInf . ' ' . "\n";
+ unset($css_charset);
+ $contents .= "\n".'// @fileRef '.$path_info.' '."\n";
$contents .= $this->js->min($file, $compact);
}
else
@@ -193,7 +194,7 @@ public function save_file($contents = '', $full_path = '')
{
$this->_ci->load->helper('file');
- if ( !write_file($full_path, $contents))
+ if ( ! write_file($full_path, $contents))
{
log_message('error', 'Minify->save_file could not write file');
return FALSE;
View
31 libraries/Minify/drivers/Minify_css.php
@@ -36,30 +36,30 @@ public function __construct()
* @param bool $compact
* @return string
*/
- public function min($file = '', $compact = TRUE, $isaggregated = NULL)
+ public function min($file = '', $compact = TRUE, $is_aggregated = NULL)
{
- if ($file == '' OR !file_exists($file))
+ if ($file == '' OR ! file_exists($file))
{
- log_message('error', 'Minify_css->min missing file ' . $file);
+ log_message('error', 'Minify_css->min missing file '.$file);
return FALSE;
}
- if (!isset($isaggregated))
+ if ( ! isset($is_aggregated))
{
$contents = file_get_contents($file);
}
else
{
- $contents = $this->removeCharsets(file_get_contents($file));
+ $contents = $this->remove_charsets(file_get_contents($file));
}
- if ( $compact != FALSE )
+ if ($compact != FALSE)
{
- return trim($this->_optimize($contents)) . "\n";
+ return trim($this->_optimize($contents))."\n";
}
else
{
- return "\n" . trim($contents) . "\n\n";
+ return "\n".trim($contents)."\n\n";
}
}
@@ -70,14 +70,14 @@ public function min($file = '', $compact = TRUE, $isaggregated = NULL)
* charset declarations removal to support do combine function
* in order to set a new one user defined charset at the beggining of the document
* to keep standars compliance (and fix Webkit buggy behaviours)
+ *
* @author F.S.Encinas
* @param string $contents
* @return string
*/
- private function removeCharsets($contents) {
-
+ private function remove_charsets($contents)
+ {
return preg_replace('/^@charset\s+[\'"](\S*)\b[\'"];/i', '', $contents);
-
}
// ------------------------------------------------------------------------
@@ -121,7 +121,7 @@ private function _optimize($contents)
# - Colon: Retain :pseudo-selectors.
'| ([\(:])\s+' .
'>xS',
- array(get_class($this), '_optimizeCB'),
+ array(get_class($this), '_optimize_call_back'),
$contents
);
@@ -132,19 +132,18 @@ private function _optimize($contents)
* Optimize CB
* Optimize Callback Helper companion for optimize fn
* based on Drupal 7 CSS Core aggregator
- *
+ *
* @author F.S.Encinas
* @param string $matches
* @return array
*/
- private function _optimizeCB($matches) {
-
+ private function _optimize_call_back($matches)
+ {
// Discard the full match.
unset($matches[0]);
// Use the non-empty match.
return current(array_filter($matches));
-
}
}
View
6 libraries/Minify/drivers/Minify_js.php
@@ -47,13 +47,13 @@ public function min($file = '', $compact = TRUE)
$contents = file_get_contents($file);
- if ( $compact != FALSE )
+ if ($compact != FALSE)
{
- return trim(JSMin::minify($contents)) . "\n";
+ return trim(JSMin::minify($contents))."\n";
}
else
{
- return "\n" . trim($contents) . "\n\n";
+ return "\n".trim($contents)."\n\n";
}
}
}
View
8 readme.md
@@ -49,14 +49,14 @@ echo $this->minify->combine_directory('test/css/, array('all.css'), [optionalPar
Optional Params
<pre>
-combine_files($files, [type], [compact], [cssCharset]);
-combine_directory($directory, [ignore], [type], [compact], [cssCharset]);
+combine_files($files, [type], [compact], [css_charset]);
+combine_directory($directory, [ignore], [type], [compact], [css_charset]);
</pre>
Common:
<pre>
[type]: string ('css' or 'js')
[compact] : bool (TRUE, FALSE). TRUE Compact/compress output, FALSE doesn't compress output (only aggregation)
-[cssCharset] : string (default 'utf-8'). If CSS you can force a starting single charset declaration (when aggregate files)
+[css_charset] : string (default 'utf-8'). If CSS you can force a starting single charset declaration (when aggregate files)
due to the charset pre-removal (for stantdars compliance and Webkit bugfix prevention)
set to null or leave empty if JS.
</pre>
@@ -66,5 +66,5 @@ Combine dir:
</pre>
## Credits
-
+fsencinas - (https://github.com/fsencinas)
JS-Min - (https://github.com/rgrove/jsmin-php)

0 comments on commit 84f19af

Please sign in to comment.
Something went wrong with that request. Please try again.