Skip to content

Commit

Permalink
Fixes coding style
Browse files Browse the repository at this point in the history
  • Loading branch information
supun-io authored and github-actions[bot] committed Oct 23, 2024
1 parent 931eab2 commit f832ceb
Show file tree
Hide file tree
Showing 11 changed files with 16 additions and 21 deletions.
2 changes: 1 addition & 1 deletion src/Embed/Embed.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ public static function getParsers(): array
{
$namespace = __NAMESPACE__ . '\\Platforms\\';
return array_map(
fn($file) => $namespace . pathinfo((string)$file, PATHINFO_FILENAME),
fn ($file) => $namespace . pathinfo((string)$file, PATHINFO_FILENAME),
(array)glob(__DIR__ . '/Platforms/*.php')
);
}
Expand Down
3 changes: 1 addition & 2 deletions src/Exception/LinkScrapeException.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,4 @@

class LinkScrapeException extends UnfoldException
{

}
}
2 changes: 0 additions & 2 deletions src/Link/Metadata/MetadataObject.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

namespace Hyvor\Unfold\Link\Metadata;


use Hyvor\Unfold\Unfolded\UnfoldedAuthor;
use Hyvor\Unfold\Unfolded\UnfoldedTag;

Expand All @@ -11,7 +10,6 @@
*/
class MetadataObject
{

/**
* @param MetadataKeyType $key
* @param T $value
Expand Down
3 changes: 0 additions & 3 deletions src/Link/Metadata/MetadataParser.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,10 @@
use Hyvor\Unfold\Link\Metadata\Parsers\OgParser;
use Hyvor\Unfold\Link\Metadata\Parsers\TitleParser;
use Hyvor\Unfold\Link\Metadata\Parsers\TwitterParser;
use Hyvor\Unfold\Unfolded\UnfoldedAuthor;
use Hyvor\Unfold\Unfolded\UnfoldedTag;
use Symfony\Component\DomCrawler\Crawler;

class MetadataParser
{

/**
* @var MetadataObject[]
*/
Expand Down
4 changes: 2 additions & 2 deletions src/Link/Metadata/MetadataPriority.php
Original file line number Diff line number Diff line change
Expand Up @@ -57,15 +57,15 @@ private function prioritizedAll(array $keys)
* 'OG_TITLE' => [MetadataObject],
* ]
*/
$keysNames = array_map(fn($key) => $key->name, $keys);
$keysNames = array_map(fn ($key) => $key->name, $keys);
uksort($keyedMetadata, function ($a, $b) use ($keysNames) {
return intval(array_search($a, $keysNames)) - intval(array_search($b, $keysNames));
});

// index by 0,1,2
$keyedMetadata = array_values($keyedMetadata);
// return the values
return array_map(fn($metadata) => $metadata->value, $keyedMetadata[0] ?? []);
return array_map(fn ($metadata) => $metadata->value, $keyedMetadata[0] ?? []);
}

/**
Expand Down
3 changes: 1 addition & 2 deletions src/UnfoldConfig.php
Original file line number Diff line number Diff line change
Expand Up @@ -81,8 +81,7 @@ public function __construct(
public ?string $facebookAccessToken = null,

// CACHE
)
{
) {
$this->setHttpClient($httpClient);
}

Expand Down
1 change: 0 additions & 1 deletion src/Unfolded/Unfolded.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

use DateTimeInterface;
use Hyvor\Unfold\Embed\EmbedResponseObject;
use Hyvor\Unfold\Link\Metadata\MetadataKeyType;
use Hyvor\Unfold\Link\Metadata\MetadataObject;
use Hyvor\Unfold\Link\Metadata\MetadataPriority;
use Hyvor\Unfold\UnfoldCallContext;
Expand Down
4 changes: 2 additions & 2 deletions tests/Feature/UnfoldEmbedTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -65,9 +65,9 @@
});

it('on unable to resolve', function () {
expect(fn() => Unfold::unfold(
expect(fn () => Unfold::unfold(
'https://hyvor.com',
method: UnfoldMethod::EMBED,
config: new UnfoldConfig()
))->toThrow(EmbedUnableToResolveException::class);
});
});
11 changes: 7 additions & 4 deletions tests/Feature/UnfoldLinkTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,10 @@

it('fetches link success', function () {
$mock = new MockHandler([
new Response(200, [], <<<HTML
new Response(
200,
[],
<<<HTML
<html lang="fr">
<head>
<title>HYVOR</title>
Expand Down Expand Up @@ -77,7 +80,7 @@
]);
$client = new Client(['handler' => $mock]);

expect(fn() => Unfold::unfold(
expect(fn () => Unfold::unfold(
'https://hyvor.com',
config: new UnfoldConfig(
httpClient: $client
Expand All @@ -97,7 +100,7 @@
]);
$client = new Client(['handler' => $mock]);

expect(fn() => Unfold::unfold(
expect(fn () => Unfold::unfold(
'https://hyvor.com',
config: new UnfoldConfig(
httpClient: $client
Expand All @@ -106,4 +109,4 @@
LinkScrapeException::class,
'Error Communicating with Server'
);
});
});
2 changes: 1 addition & 1 deletion tests/Unit/EmbedParsers/Platforms/InstagramTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -131,4 +131,4 @@
['id' => 'C6H039Ctw_b', 'type' => 'tv']
]

]);
]);
2 changes: 1 addition & 1 deletion tests/Unit/Link/Metadata/MetadataPriorityTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -175,4 +175,4 @@
$priority = new MetadataPriority([$metadata]);
expect($priority->locale())->toBe('en');
});
});
});

0 comments on commit f832ceb

Please sign in to comment.