Skip to content

Commit 9c68670

Browse files
committed
Finished the 'html first' flow
1 parent 675fe7c commit 9c68670

File tree

2 files changed

+11
-13
lines changed

2 files changed

+11
-13
lines changed

src/HtmlStore.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,14 @@
22

33
namespace PageSpecificCss;
44

5-
use TijsVerkoyen\CssToInlineStyles\Css\Property\Property;
6-
75
class HtmlStore
86
{
97
/** @var array Property objects, grouped by selector */
108
private $snippets = [];
119

1210
public function addHtmlSnippet($htmlSnippet)
1311
{
14-
$this->snippets = array_merge($this->snippets, $htmlSnippet);
12+
$this->snippets = array_merge($this->snippets, [$htmlSnippet]);
1513
return $this;
1614
}
1715

src/PageSpecificCss.php

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ class PageSpecificCss extends CssToInlineStyles
2222
private $processor;
2323

2424
/** @var Rule[] */
25-
private $rules;
25+
private $rules = [];
2626

2727
/** @var HtmlStore */
2828
private $htmlStore;
@@ -50,20 +50,12 @@ public function getHtmlStore()
5050
return $this->htmlStore;
5151
}
5252

53-
/**
54-
* @param string $html the raw html
55-
*/
56-
public function processHtmlToStore($html)
57-
{
58-
$this->cssStore->addCssStyles($this->extractCss($html));
59-
}
60-
6153
/**
6254
* @param $sourceCss
6355
*/
6456
public function addBaseRules($sourceCss)
6557
{
66-
$this->rules = array_merge($this->rules, $this->processor->getRules($sourceCss));
58+
$this->rules = $this->processor->getRules($sourceCss, $this->rules);
6759
}
6860

6961
public function buildExtractedRuleSet()
@@ -75,6 +67,14 @@ public function buildExtractedRuleSet()
7567
return $this->cssStore->compileStyles();
7668
}
7769

70+
/**
71+
* @param string $html the raw html
72+
*/
73+
public function processHtmlToStore($html)
74+
{
75+
$this->cssStore->addCssStyles($this->extractCss($html));
76+
}
77+
7878
/**
7979
* @param $html
8080
*

0 commit comments

Comments
 (0)