From 8f142eb03bc06417287f502cd8ac3c5f62aa4812 Mon Sep 17 00:00:00 2001 From: Phan An Date: Tue, 10 Mar 2020 11:16:55 +0100 Subject: [PATCH] Apply fixes from StyleCI (#1194) --- app/Services/FileSynchronizer.php | 5 +++-- app/Services/InteractionService.php | 5 +++-- app/Services/YouTubeService.php | 3 ++- app/Services/iTunesService.php | 4 +++- 4 files changed, 11 insertions(+), 6 deletions(-) diff --git a/app/Services/FileSynchronizer.php b/app/Services/FileSynchronizer.php index b9c0865e..bd78b62e 100644 --- a/app/Services/FileSynchronizer.php +++ b/app/Services/FileSynchronizer.php @@ -249,7 +249,8 @@ class FileSynchronizer { // As directory scanning can be expensive, we cache and reuse the result. return $this->cache->remember(md5($this->filePath.'_cover'), 24 * 60, function (): ?string { - $matches = array_keys(iterator_to_array( + $matches = array_keys( + iterator_to_array( $this->finder->create() ->depth(0) ->ignoreUnreadableDirs() @@ -257,7 +258,7 @@ class FileSynchronizer ->followLinks() ->name('/(cov|fold)er\.(jpe?g|png)$/i') ->in(dirname($this->filePath)) - ) + ) ); $cover = $matches ? $matches[0] : null; diff --git a/app/Services/InteractionService.php b/app/Services/InteractionService.php index 83827a94..0424987b 100644 --- a/app/Services/InteractionService.php +++ b/app/Services/InteractionService.php @@ -90,12 +90,13 @@ class InteractionService ->whereIn('song_id', $songIds) ->where('user_id', $user->id) ->get() - ->each(static function (Interaction $interaction): void { + ->each( + static function (Interaction $interaction): void { $interaction->liked = false; $interaction->save(); event(new SongLikeToggled($interaction)); } - ); + ); } } diff --git a/app/Services/YouTubeService.php b/app/Services/YouTubeService.php index c5a2e498..f235c0b2 100644 --- a/app/Services/YouTubeService.php +++ b/app/Services/YouTubeService.php @@ -47,7 +47,8 @@ class YouTubeService extends AbstractApiClient implements ApiConsumerInterface return null; } - $uri = sprintf('search?part=snippet&type=video&maxResults=%s&pageToken=%s&q=%s', + $uri = sprintf( + 'search?part=snippet&type=video&maxResults=%s&pageToken=%s&q=%s', $perPage, urlencode($pageToken), urlencode($q) diff --git a/app/Services/iTunesService.php b/app/Services/iTunesService.php index d05e64f7..4d4b306e 100644 --- a/app/Services/iTunesService.php +++ b/app/Services/iTunesService.php @@ -24,7 +24,9 @@ class iTunesService extends AbstractApiClient implements ApiConsumerInterface public function getTrackUrl(string $term, string $album = '', string $artist = ''): ?string { try { - return $this->cache->remember(md5("itunes_track_url_{$term}{$album}{$artist}"), 24 * 60 * 7, + return $this->cache->remember( + md5("itunes_track_url_{$term}{$album}{$artist}"), + 24 * 60 * 7, function () use ($term, $album, $artist): ?string { $params = [ 'term' => $term.($album ? " $album" : '').($artist ? " $artist" : ''),