Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@
"autoload": {
"classmap": ["src/"]
},
"scripts": {
"analyse": "phpstan analyse --memory-limit=512M",
"test": "phpunit"
},
"require-dev": {
"phpunit/phpunit": "^10.5",
"phpstan/phpstan": "^1.10"
Expand Down
4 changes: 2 additions & 2 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions phpstan.neon
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
parameters:
level: 5
paths:
- src
4 changes: 4 additions & 0 deletions src/cssdoc.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@
namespace hexydec\css;
use \hexydec\tokens\tokenise;

/**
* @property-read array<mixed> $config The object configuration array
* @property-read int $length The number of children in the document
*/
class cssdoc extends config implements \ArrayAccess, \Iterator {

/**
Expand Down
37 changes: 37 additions & 0 deletions tests/findcssdocTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
<?php
use hexydec\css\cssdoc;

final class findCssdocTest extends \PHPUnit\Framework\TestCase {

public function testCanFindRules() {
$css = '
#id {
display: block;
background: green;
color: white;
}
input[type=submit].form__control-submit {
border: 1px solid red;
padding: 10px;
}
';
$tests = [
[
'find' => '#id',
'props' => [],
'exact' => true,
'output' => '#id {
display: block;
background: green;
color: white;
}'
]
];
$obj = new cssdoc();
$obj->load($css);
foreach ($tests AS $item) {
$doc = $obj->find($item['find'], $item['props'], [], $item['exact']);
$this->assertEquals($item['output'], $doc->compile());
}
}
}
Loading