|
2 | 2 |
|
3 | 3 | namespace Fusonic\OpenGraph; |
4 | 4 |
|
5 | | -use DOMElement; |
6 | | -use Fusonic\Linq\Linq; |
7 | 5 | use Fusonic\OpenGraph\Objects\ObjectBase; |
8 | 6 | use Fusonic\OpenGraph\Objects\Website; |
9 | 7 | use LogicException; |
@@ -97,32 +95,20 @@ private function extractOpenGraphData(string $content): ObjectBase |
97 | 95 | { |
98 | 96 | // Get all meta-tags starting with "og:" |
99 | 97 | $ogMetaTags = $crawler->filter("meta[{$t}^='og:']"); |
| 98 | + |
100 | 99 | // 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 | + |
110 | 107 | $properties = array_merge($properties, $props); |
111 | | - |
112 | 108 | } |
113 | 109 |
|
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(); |
126 | 112 |
|
127 | 113 | // Assign all properties to the object |
128 | 114 | $object->assignProperties($properties, $this->debug); |
|
0 commit comments