@@ -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($content); |
@@ -92,6 +95,10 @@ discard block |
||
| 92 | 95 | // Create clean property array |
| 93 | 96 | $props = Linq::from($ogMetaTags) |
| 94 | 97 | ->select( |
| 98 | + |
|
| 99 | + /** |
|
| 100 | + * @param string $tag |
|
| 101 | + */ |
|
| 95 | 102 | function (\DOMElement $tag) use ($t) { |
| 96 | 103 | $name = strtolower(trim($tag->getAttribute($t))); |
| 97 | 104 | $value = trim($tag->getAttribute("content")); |
@@ -106,6 +113,10 @@ discard block |
||
| 106 | 113 | // Create new object of the correct type |
| 107 | 114 | $typeProperty = Linq::from($properties) |
| 108 | 115 | ->firstOrNull( |
| 116 | + |
|
| 117 | + /** |
|
| 118 | + * @param string $property |
|
| 119 | + */ |
|
| 109 | 120 | function (Property $property) { |
| 110 | 121 | return $property->key === Property::TYPE; |
| 111 | 122 | } |
@@ -85,14 +85,14 @@ discard block |
||
| 85 | 85 | $crawler = new Crawler($content); |
| 86 | 86 | |
| 87 | 87 | $properties = []; |
| 88 | - foreach(['name', 'property'] as $t) |
|
| 88 | + foreach (['name', 'property'] as $t) |
|
| 89 | 89 | { |
| 90 | 90 | // Get all meta-tags starting with "og:" |
| 91 | 91 | $ogMetaTags = $crawler->filter("meta[{$t}^='og:']"); |
| 92 | 92 | // Create clean property array |
| 93 | 93 | $props = Linq::from($ogMetaTags) |
| 94 | 94 | ->select( |
| 95 | - function (\DOMElement $tag) use ($t) { |
|
| 95 | + function(\DOMElement $tag) use ($t) { |
|
| 96 | 96 | $name = strtolower(trim($tag->getAttribute($t))); |
| 97 | 97 | $value = trim($tag->getAttribute("content")); |
| 98 | 98 | return new Property($name, $value); |
@@ -106,13 +106,12 @@ discard block |
||
| 106 | 106 | // Create new object of the correct type |
| 107 | 107 | $typeProperty = Linq::from($properties) |
| 108 | 108 | ->firstOrNull( |
| 109 | - function (Property $property) { |
|
| 109 | + function(Property $property) { |
|
| 110 | 110 | return $property->key === Property::TYPE; |
| 111 | 111 | } |
| 112 | 112 | ); |
| 113 | 113 | switch ($typeProperty !== null ? $typeProperty->value : null) { |
| 114 | - default: |
|
| 115 | - $object = new Website(); |
|
| 114 | + default : $object = new Website(); |
|
| 116 | 115 | break; |
| 117 | 116 | } |
| 118 | 117 | |
@@ -27,7 +27,7 @@ |
||
| 27 | 27 | public function generateHtml(ObjectBase $object) |
| 28 | 28 | { |
| 29 | 29 | $html = ""; |
| 30 | - $format = "<meta property=\"%s\" content=\"%s\"" . ($this->doctype == self::DOCTYPE_XHTML ? " />" : ">"); |
|
| 30 | + $format = "<meta property=\"%s\" content=\"%s\"".($this->doctype == self::DOCTYPE_XHTML ? " />" : ">"); |
|
| 31 | 31 | |
| 32 | 32 | foreach ($object->getProperties() as $property) { |
| 33 | 33 | if ($html !== "") { |
@@ -129,7 +129,7 @@ discard block |
||
| 129 | 129 | $name = $property->key; |
| 130 | 130 | $value = $property->value; |
| 131 | 131 | |
| 132 | - switch($name) { |
|
| 132 | + switch ($name) { |
|
| 133 | 133 | case Property::AUDIO: |
| 134 | 134 | case Property::AUDIO_URL: |
| 135 | 135 | $this->audios[] = new Audio($value); |
@@ -235,7 +235,7 @@ discard block |
||
| 235 | 235 | |
| 236 | 236 | private function handleImageAttribute(Image $element, $name, $value) |
| 237 | 237 | { |
| 238 | - switch($name) |
|
| 238 | + switch ($name) |
|
| 239 | 239 | { |
| 240 | 240 | case Property::IMAGE_HEIGHT: |
| 241 | 241 | $element->height = (int)$value; |
@@ -257,7 +257,7 @@ discard block |
||
| 257 | 257 | |
| 258 | 258 | private function handleVideoAttribute(Video $element, $name, $value) |
| 259 | 259 | { |
| 260 | - switch($name) |
|
| 260 | + switch ($name) |
|
| 261 | 261 | { |
| 262 | 262 | case Property::VIDEO_HEIGHT: |
| 263 | 263 | $element->height = (int)$value; |
@@ -276,7 +276,7 @@ discard block |
||
| 276 | 276 | |
| 277 | 277 | private function handleAudioAttribute(Audio $element, $name, $value) |
| 278 | 278 | { |
| 279 | - switch($name) |
|
| 279 | + switch ($name) |
|
| 280 | 280 | { |
| 281 | 281 | case Property::AUDIO_TYPE: |
| 282 | 282 | $element->type = $value; |
@@ -294,7 +294,7 @@ discard block |
||
| 294 | 294 | |
| 295 | 295 | protected function convertToBoolean($value) |
| 296 | 296 | { |
| 297 | - switch(strtolower($value)) |
|
| 297 | + switch (strtolower($value)) |
|
| 298 | 298 | { |
| 299 | 299 | case "1": |
| 300 | 300 | case "true": |