@@ -80,6 +80,9 @@ discard block |
||
| 80 | 80 | return $page; |
| 81 | 81 | } |
| 82 | 82 | |
| 83 | + /** |
|
| 84 | + * @param string $content |
|
| 85 | + */ |
|
| 83 | 86 | private function extractOpenGraphData($content) |
| 84 | 87 | { |
| 85 | 88 | $crawler = new Crawler; |
@@ -93,6 +96,10 @@ discard block |
||
| 93 | 96 | // Create clean property array |
| 94 | 97 | $props = Linq::from($ogMetaTags) |
| 95 | 98 | ->select( |
| 99 | + |
|
| 100 | + /** |
|
| 101 | + * @param string $tag |
|
| 102 | + */ |
|
| 96 | 103 | function (\DOMElement $tag) use ($t) { |
| 97 | 104 | $name = strtolower(trim($tag->getAttribute($t))); |
| 98 | 105 | $value = trim($tag->getAttribute("content")); |
@@ -107,6 +114,10 @@ discard block |
||
| 107 | 114 | // Create new object of the correct type |
| 108 | 115 | $typeProperty = Linq::from($properties) |
| 109 | 116 | ->firstOrNull( |
| 117 | + |
|
| 118 | + /** |
|
| 119 | + * @param string $property |
|
| 120 | + */ |
|
| 110 | 121 | function (Property $property) { |
| 111 | 122 | return $property->key === Property::TYPE; |
| 112 | 123 | } |
@@ -86,14 +86,14 @@ discard block |
||
| 86 | 86 | $crawler->addHTMLContent($content, 'UTF-8'); |
| 87 | 87 | |
| 88 | 88 | $properties = []; |
| 89 | - foreach(['name', 'property'] as $t) |
|
| 89 | + foreach (['name', 'property'] as $t) |
|
| 90 | 90 | { |
| 91 | 91 | // Get all meta-tags starting with "og:" |
| 92 | 92 | $ogMetaTags = $crawler->filter("meta[{$t}^='og:']"); |
| 93 | 93 | // Create clean property array |
| 94 | 94 | $props = Linq::from($ogMetaTags) |
| 95 | 95 | ->select( |
| 96 | - function (\DOMElement $tag) use ($t) { |
|
| 96 | + function(\DOMElement $tag) use ($t) { |
|
| 97 | 97 | $name = strtolower(trim($tag->getAttribute($t))); |
| 98 | 98 | $value = trim($tag->getAttribute("content")); |
| 99 | 99 | return new Property($name, $value); |
@@ -107,13 +107,12 @@ discard block |
||
| 107 | 107 | // Create new object of the correct type |
| 108 | 108 | $typeProperty = Linq::from($properties) |
| 109 | 109 | ->firstOrNull( |
| 110 | - function (Property $property) { |
|
| 110 | + function(Property $property) { |
|
| 111 | 111 | return $property->key === Property::TYPE; |
| 112 | 112 | } |
| 113 | 113 | ); |
| 114 | 114 | switch ($typeProperty !== null ? $typeProperty->value : null) { |
| 115 | - default: |
|
| 116 | - $object = new Website(); |
|
| 115 | + default : $object = new Website(); |
|
| 117 | 116 | break; |
| 118 | 117 | } |
| 119 | 118 | |