Skip to content

Commit

Permalink
Improved code climate, added µf2 tests
Browse files Browse the repository at this point in the history
  • Loading branch information
jkphl committed Mar 3, 2017
1 parent 8090aa6 commit 5e0372d
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 16 deletions.
10 changes: 8 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
"name": "jkphl/micrometa",
"description": "A meta parser for extracting micro information out of web documents, currently supporting Microformats 1+2, HTML Microdata, RDFa Lite 1.1 and JSON-LD",
"homepage": "https://jkphl.is/projects/micrometa/",
"minimum-stability": "RC",
"minimum-stability": "dev",
"prefer-stable" : true,
"license": "MIT",
"authors": [
{
Expand All @@ -24,6 +25,10 @@
"graph-composer": {
"type": "git",
"url": "https://github.com/jkphl/graph-composer"
},
"microformats-tests": {
"type": "vcs",
"url": "https://github.com/microformats/tests"
}
},
"require": {
Expand Down Expand Up @@ -51,6 +56,7 @@
"codeclimate/php-test-reporter": "^0.4.4",
"phpunit/phpunit": "^4.8",
"satooshi/php-coveralls": "^1.0",
"squizlabs/php_codesniffer": "^2.8"
"squizlabs/php_codesniffer": "^2.8",
"microformats/test": "@dev"
}
}
28 changes: 14 additions & 14 deletions src/Micrometa/Ports/Item/ItemList.php
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ public function next()
/**
* Return the position of the current element
*
* @return mixed Position of the current element
* @return int Position of the current element
*/
public function key()
{
Expand Down Expand Up @@ -153,18 +153,6 @@ public function item(...$types)
return $this->items(...$types)[0];
}

/**
* Filter the items by item type(s)
*
* @param array ...$types Item types
* @return ItemListInterface Items matching the requested types
* @api
*/
public function filter(...$types)
{
return new static($this->items(...$types));
}

/**
* Return all items as an array, optionally filtered by item type(s)
*
Expand All @@ -178,12 +166,24 @@ public function items(...$types)
if (count($types)) {
return array_filter(
$this->items,
function (ItemInterface $item) use ($types) {
function(ItemInterface $item) use ($types) {
return $item->isOfType(...$types);
}
);
}

return $this->items;
}

/**
* Filter the items by item type(s)
*
* @param array ...$types Item types
* @return ItemListInterface Items matching the requested types
* @api
*/
public function filter(...$types)
{
return new static($this->items(...$types));
}
}

0 comments on commit 5e0372d

Please sign in to comment.