Skip to content

Commit

Permalink
Moved parser to own class
Browse files Browse the repository at this point in the history
  • Loading branch information
JakubOnderka committed Nov 23, 2011
1 parent fedaa52 commit 719fa98
Show file tree
Hide file tree
Showing 14 changed files with 2,672 additions and 891 deletions.
865 changes: 7 additions & 858 deletions lib/CSSTidy.php

Large diffs are not rendered by default.

17 changes: 16 additions & 1 deletion lib/Container.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
/**
* @property \CSSTidy\Logger $logger
* @property \CSSTidy\Configuration $configuration
* @property \CSSTidy\Parser $parser
* @property \CSSTidy\SelectorManipulate $selectorManipulate
* @property \CSSTidy\Optimise\Value $optimiseValue
* @property \CSSTidy\Optimise\Color $optimiseColor
Expand All @@ -53,13 +54,27 @@ public function __construct()
require_once __DIR__ . '/Configuration.php';
return new Configuration;
},
'parser' => function() use ($cont) {
require_once __DIR__ . '/Parser.php';
return new Parser(
$cont->logger,
$cont->configuration->getDiscardInvalidProperties(),
$cont->configuration->getCssLevel(),
$cont->configuration->getRemoveBackSlash()
);
},
'selectorManipulate' => function() {
require_once __DIR__ . '/SelectorManipulate.php';
return new SelectorManipulate;
},
'optimiseValue' => function() use ($cont) {
require_once __DIR__ . '/optimise/Value.php';
return new \CSSTidy\Optimise\Value($cont->logger, $cont->configuration, $cont->optimiseColor, $cont->optimiseNumber);
return new \CSSTidy\Optimise\Value(
$cont->logger,
$cont->configuration,
$cont->optimiseColor,
$cont->optimiseNumber
);
},
'optimiseColor' => function() use($cont) {
require_once __DIR__ . '/optimise/Color.php';
Expand Down
17 changes: 0 additions & 17 deletions lib/Logger.php
Original file line number Diff line number Diff line change
Expand Up @@ -59,23 +59,6 @@ public function log($message, $type, $line = -1)
}
}

/**
* @param int $count
* @return int
*/
public function incrementLine($count = 1)
{
return $this->line += $count;
}

/**
* @return int
*/
public function getCurrentLine()
{
return $this->line;
}

/**
* @return array
*/
Expand Down
9 changes: 5 additions & 4 deletions lib/Output.php
Original file line number Diff line number Diff line change
Expand Up @@ -270,13 +270,14 @@ protected function tokensToCss(Template $template, $plain)
}

foreach ($this->parsed->import as $import) {
$replaced = $this->removeUrl($import);
if ($replaced !== $import) {
$import = $replaced;
$importValue = $import->getValue();
$replaced = $this->removeUrl($importValue);
if ($replaced !== $importValue) {
$importValue = $replaced;
$this->logger->log('Optimised @import: Removed "url("', Logger::INFORMATION);
}

$output .= "{$template->beforeAtRule}@import{$template->beforeValue}{$import}{$template->afterValueWithSemicolon}";
$output .= "{$template->beforeAtRule}@import{$template->beforeValue}{$importValue}{$template->afterValueWithSemicolon}";
}

foreach ($this->parsed->namespace as $namespace) {
Expand Down
Loading

0 comments on commit 719fa98

Please sign in to comment.