Skip to content

Commit 09dca70

Browse files
authored
fix(#34): Dropped dependency to deprecated fusonic/linq library (#35)
1 parent d3a41c7 commit 09dca70

File tree

2 files changed

+10
-25
lines changed

2 files changed

+10
-25
lines changed

composer.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@
2626
"ext-dom": "*",
2727
"symfony/dom-crawler": "^3.0|^4.0|^5.0|^6.0",
2828
"symfony/css-selector": "^3.0|^4.0|^5.0|^6.0",
29-
"fusonic/linq": "^1.0",
3029
"psr/http-client": "^1.0",
3130
"psr/http-factory": "^1.0"
3231
},

src/Consumer.php

Lines changed: 10 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,6 @@
22

33
namespace Fusonic\OpenGraph;
44

5-
use DOMElement;
6-
use Fusonic\Linq\Linq;
75
use Fusonic\OpenGraph\Objects\ObjectBase;
86
use Fusonic\OpenGraph\Objects\Website;
97
use LogicException;
@@ -97,32 +95,20 @@ private function extractOpenGraphData(string $content): ObjectBase
9795
{
9896
// Get all meta-tags starting with "og:"
9997
$ogMetaTags = $crawler->filter("meta[{$t}^='og:']");
98+
10099
// Create clean property array
101-
$props = Linq::from($ogMetaTags)
102-
->select(
103-
function (DOMElement $tag) use ($t) {
104-
$name = strtolower(trim($tag->getAttribute($t)));
105-
$value = trim($tag->getAttribute("content"));
106-
return new Property($name, $value);
107-
}
108-
)
109-
->toArray();
100+
$props = [];
101+
foreach ($ogMetaTags as $tag) {
102+
$name = strtolower(trim($tag->getAttribute($t)));
103+
$value = trim($tag->getAttribute("content"));
104+
$props[] = new Property($name, $value);
105+
}
106+
110107
$properties = array_merge($properties, $props);
111-
112108
}
113109

114-
// Create new object of the correct type
115-
$typeProperty = Linq::from($properties)
116-
->firstOrNull(
117-
function (Property $property) {
118-
return $property->key === Property::TYPE;
119-
}
120-
);
121-
switch ($typeProperty !== null ? $typeProperty->value : null) {
122-
default:
123-
$object = new Website();
124-
break;
125-
}
110+
// Create new object
111+
$object = new Website();
126112

127113
// Assign all properties to the object
128114
$object->assignProperties($properties, $this->debug);

0 commit comments

Comments
 (0)