]> git.mxchange.org Git - friendica.git/commitdiff
Fix code style
authorArt4 <art4@wlabs.de>
Fri, 14 Feb 2025 12:15:17 +0000 (12:15 +0000)
committerArt4 <art4@wlabs.de>
Fri, 14 Feb 2025 12:15:17 +0000 (12:15 +0000)
src/Content/OEmbed.php
tests/Unit/Core/Hooks/HookEventBridgeTest.php

index 217f42f0ebeb698e44b9259cf6af099b8e9b2461..93833630124fa74f26b3a77eba2945a82dd7557b 100644 (file)
@@ -53,7 +53,7 @@ class OEmbed
 
                $cache_key = 'oembed:' . $appHelper->getThemeInfoValue('videowidth') . ':' . $embedurl;
 
-               $condition = ['url' => Strings::normaliseLink($embedurl), 'maxwidth' => $appHelper->getThemeInfoValue('videowidth')];
+               $condition     = ['url' => Strings::normaliseLink($embedurl), 'maxwidth' => $appHelper->getThemeInfoValue('videowidth')];
                $oembed_record = DBA::selectFirst('oembed', ['content'], $condition);
                if (DBA::isResult($oembed_record)) {
                        $json_string = $oembed_record['content'];
@@ -64,7 +64,7 @@ class OEmbed
                // These media files should now be caught in bbcode.php
                // left here as a fallback in case this is called from another source
                $noexts = ['mp3', 'mp4', 'ogg', 'ogv', 'oga', 'ogm', 'webm'];
-               $ext = pathinfo(strtolower($embedurl), PATHINFO_EXTENSION);
+               $ext    = pathinfo(strtolower($embedurl), PATHINFO_EXTENSION);
 
                $oembed = new \Friendica\Object\OEmbed($embedurl);
 
@@ -81,15 +81,17 @@ class OEmbed
                                        if (@$dom->loadHTML($html_text)) {
                                                $xpath = new DOMXPath($dom);
                                                foreach (
-                                                       $xpath->query("//link[@type='application/json+oembed'] | //link[@type='text/json+oembed']")
-                                                       as $link)
-                                               {
+                                                       $xpath->query("//link[@type='application/json+oembed'] | //link[@type='text/json+oembed']") as $link
+                                               ) {
                                                        /** @var DOMElement $link */
                                                        $href = $link->getAttributeNode('href')->nodeValue;
                                                        // Both Youtube and Vimeo output OEmbed endpoint URL with HTTP
                                                        // but their OEmbed endpoint is only accessible by HTTPS ¯\_(ツ)_/¯
-                                                       $href = str_replace(['http://www.youtube.com/', 'http://player.vimeo.com/'],
-                                                               ['https://www.youtube.com/', 'https://player.vimeo.com/'], $href);
+                                                       $href = str_replace(
+                                                               ['http://www.youtube.com/', 'http://player.vimeo.com/'],
+                                                               ['https://www.youtube.com/', 'https://player.vimeo.com/'],
+                                                               $href
+                                                       );
                                                        $result = DI::httpClient()->get($href . '&maxwidth=' . $appHelper->getThemeInfoValue('videowidth'), HttpClientAccept::DEFAULT, [HttpClientOptions::REQUEST => HttpClientRequest::SITEINFO]);
                                                        if ($result->isSuccess()) {
                                                                $json_string = $result->getBodyString();
@@ -110,10 +112,10 @@ class OEmbed
 
                        if (!empty($oembed->type) && $oembed->type != 'error') {
                                DBA::insert('oembed', [
-                                       'url' => Strings::normaliseLink($embedurl),
+                                       'url'      => Strings::normaliseLink($embedurl),
                                        'maxwidth' => $appHelper->getThemeInfoValue('videowidth'),
-                                       'content' => $json_string,
-                                       'created' => DateTimeFormat::utcNow()
+                                       'content'  => $json_string,
+                                       'created'  => DateTimeFormat::utcNow()
                                ], Database::INSERT_UPDATE);
                                $cache_ttl = Duration::DAY;
                        } else {
@@ -141,8 +143,8 @@ class OEmbed
 
                        if ($oembed->type == 'photo') {
                                if (!empty($data['images'])) {
-                                       $oembed->url = $data['images'][0]['src'];
-                                       $oembed->width = $data['images'][0]['width'];
+                                       $oembed->url    = $data['images'][0]['src'];
+                                       $oembed->width  = $data['images'][0]['width'];
                                        $oembed->height = $data['images'][0]['height'];
                                } else {
                                        $oembed->type = 'link';
@@ -175,8 +177,8 @@ class OEmbed
                }
 
                if (!empty($data['images']) && ($oembed->type != 'photo')) {
-                       $oembed->thumbnail_url = $data['images'][0]['src'];
-                       $oembed->thumbnail_width = $data['images'][0]['width'];
+                       $oembed->thumbnail_url    = $data['images'][0]['src'];
+                       $oembed->thumbnail_width  = $data['images'][0]['width'];
                        $oembed->thumbnail_height = $data['images'][0]['height'];
                }
 
@@ -210,15 +212,15 @@ class OEmbed
                                        // make sure we don't attempt divide by zero, fallback is a 1:1 ratio
                                        $tr = (($th) ? $tw / $th : 1);
 
-                                       $th = 120;
-                                       $tw = $th * $tr;
+                                       $th  = 120;
+                                       $tw  = $th * $tr;
                                        $tpl = Renderer::getMarkupTemplate('oembed_video.tpl');
                                        $ret .= Renderer::replaceMacros($tpl, [
-                                               '$embedurl' => $oembed->embed_url,
+                                               '$embedurl'    => $oembed->embed_url,
                                                '$escapedhtml' => base64_encode($oembed->html),
-                                               '$tw' => $tw,
-                                               '$th' => $th,
-                                               '$turl' => BBCode::proxyUrl($oembed->thumbnail_url, BBCode::INTERNAL, $uriid, Proxy::SIZE_SMALL),
+                                               '$tw'          => $tw,
+                                               '$th'          => $th,
+                                               '$turl'        => BBCode::proxyUrl($oembed->thumbnail_url, BBCode::INTERNAL, $uriid, Proxy::SIZE_SMALL),
                                        ]);
                                } else {
                                        $ret .= Proxy::proxifyHtml($oembed->html, $uriid);
@@ -285,7 +287,7 @@ class OEmbed
                }
 
                $ret .= '</div>';
-$test = Proxy::proxifyHtml($ret, $uriid);
+               $test = Proxy::proxifyHtml($ret, $uriid);
 
                return str_replace("\n", "", $ret);
        }
index ea46230399d03ce100c6cb32df63398d13e89a33..44b727cf71822a19b503105aed3b95394c60a9d7 100644 (file)
@@ -164,7 +164,7 @@ class HookEventBridgeTest extends TestCase
                $reflectionProperty = new \ReflectionProperty(HookEventBridge::class, 'mockedCallHook');
                $reflectionProperty->setAccessible(true);
 
-               $reflectionProperty->setValue(null, function (string $name, $data): string  {
+               $reflectionProperty->setValue(null, function (string $name, string $data): string {
                        $this->assertSame('oembed_fetch_url', $name);
                        $this->assertSame('original_url', $data);