@@ -6,7 +6,7 @@ |
||
| 6 | 6 | use Fusonic\OpenGraph\Objects\Website; |
| 7 | 7 | use Fusonic\OpenGraph\Publisher; |
| 8 | 8 | |
| 9 | -require __DIR__ . "/../vendor/autoload.php"; |
|
| 9 | +require __DIR__."/../vendor/autoload.php"; |
|
| 10 | 10 | |
| 11 | 11 | // Construct a new Open Graph object |
| 12 | 12 | $website = new Website(); |
@@ -93,14 +93,14 @@ discard block |
||
| 93 | 93 | $crawler->addHTMLContent($content, 'UTF-8'); |
| 94 | 94 | |
| 95 | 95 | $properties = []; |
| 96 | - foreach(['name', 'property'] as $t) |
|
| 96 | + foreach (['name', 'property'] as $t) |
|
| 97 | 97 | { |
| 98 | 98 | // Get all meta-tags starting with "og:" |
| 99 | 99 | $ogMetaTags = $crawler->filter("meta[{$t}^='og:']"); |
| 100 | 100 | // Create clean property array |
| 101 | 101 | $props = Linq::from($ogMetaTags) |
| 102 | 102 | ->select( |
| 103 | - function (DOMElement $tag) use ($t) { |
|
| 103 | + function(DOMElement $tag) use ($t) { |
|
| 104 | 104 | $name = strtolower(trim($tag->getAttribute($t))); |
| 105 | 105 | $value = trim($tag->getAttribute("content")); |
| 106 | 106 | return new Property($name, $value); |
@@ -114,13 +114,12 @@ discard block |
||
| 114 | 114 | // Create new object of the correct type |
| 115 | 115 | $typeProperty = Linq::from($properties) |
| 116 | 116 | ->firstOrNull( |
| 117 | - function (Property $property) { |
|
| 117 | + function(Property $property) { |
|
| 118 | 118 | return $property->key === Property::TYPE; |
| 119 | 119 | } |
| 120 | 120 | ); |
| 121 | 121 | switch ($typeProperty !== null ? $typeProperty->value : null) { |
| 122 | - default: |
|
| 123 | - $object = new Website(); |
|
| 122 | + default : $object = new Website(); |
|
| 124 | 123 | break; |
| 125 | 124 | } |
| 126 | 125 | |
@@ -111,7 +111,7 @@ discard block |
||
| 111 | 111 | $name = $property->key; |
| 112 | 112 | $value = $property->value; |
| 113 | 113 | |
| 114 | - switch($name) { |
|
| 114 | + switch ($name) { |
|
| 115 | 115 | case Property::AUDIO: |
| 116 | 116 | case Property::AUDIO_URL: |
| 117 | 117 | $this->audios[] = new Audio($value); |
@@ -215,7 +215,7 @@ discard block |
||
| 215 | 215 | |
| 216 | 216 | private function handleImageAttribute(Image $element, string $name, string $value): void |
| 217 | 217 | { |
| 218 | - switch($name) |
|
| 218 | + switch ($name) |
|
| 219 | 219 | { |
| 220 | 220 | case Property::IMAGE_HEIGHT: |
| 221 | 221 | $element->height = (int)$value; |
@@ -237,7 +237,7 @@ discard block |
||
| 237 | 237 | |
| 238 | 238 | private function handleVideoAttribute(Video $element, string $name, string $value): void |
| 239 | 239 | { |
| 240 | - switch($name) |
|
| 240 | + switch ($name) |
|
| 241 | 241 | { |
| 242 | 242 | case Property::VIDEO_HEIGHT: |
| 243 | 243 | $element->height = (int)$value; |
@@ -256,7 +256,7 @@ discard block |
||
| 256 | 256 | |
| 257 | 257 | private function handleAudioAttribute(Audio $element, string $name, string $value): void |
| 258 | 258 | { |
| 259 | - switch($name) |
|
| 259 | + switch ($name) |
|
| 260 | 260 | { |
| 261 | 261 | case Property::AUDIO_TYPE: |
| 262 | 262 | $element->type = $value; |
@@ -278,7 +278,7 @@ discard block |
||
| 278 | 278 | |
| 279 | 279 | protected function convertToBoolean(string $value): bool |
| 280 | 280 | { |
| 281 | - switch(strtolower($value)) |
|
| 281 | + switch (strtolower($value)) |
|
| 282 | 282 | { |
| 283 | 283 | case "1": |
| 284 | 284 | case "true": |
@@ -30,7 +30,7 @@ |
||
| 30 | 30 | public function generateHtml(ObjectBase $object): string |
| 31 | 31 | { |
| 32 | 32 | $html = ""; |
| 33 | - $format = "<meta property=\"%s\" content=\"%s\"" . ($this->doctype == self::DOCTYPE_XHTML ? " />" : ">"); |
|
| 33 | + $format = "<meta property=\"%s\" content=\"%s\"".($this->doctype == self::DOCTYPE_XHTML ? " />" : ">"); |
|
| 34 | 34 | |
| 35 | 35 | foreach ($object->getProperties() as $property) { |
| 36 | 36 | if ($html !== "") { |
@@ -3,11 +3,11 @@ |
||
| 3 | 3 | use Symfony\Component\HttpClient\NativeHttpClient; |
| 4 | 4 | use Symfony\Component\HttpClient\Psr18Client; |
| 5 | 5 | |
| 6 | -require __DIR__ . "/../vendor/autoload.php"; |
|
| 6 | +require __DIR__."/../vendor/autoload.php"; |
|
| 7 | 7 | |
| 8 | 8 | // Initialize new Psr\HttpClient implementation. This example uses Symfony's implementation from the symfony/http-client |
| 9 | 9 | // package but you can use any implementation provided by your framework of choice. |
| 10 | -$client = new Psr18Client(new NativeHttpClient([ "headers" => [ "User-Agent" => "facebookexternalhit/1.1" ] ])); |
|
| 10 | +$client = new Psr18Client(new NativeHttpClient(["headers" => ["User-Agent" => "facebookexternalhit/1.1"]])); |
|
| 11 | 11 | |
| 12 | 12 | // Create a new crawler |
| 13 | 13 | $crawler = new Fusonic\OpenGraph\Consumer($client, $client); |