Apply fixes from StyleCI (#793)

This commit is contained in:
Phan An 2018-08-29 11:42:11 +02:00 committed by GitHub
parent 1558062428
commit fe34592e66
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 14 additions and 14 deletions

View file

@ -107,7 +107,7 @@ class SyncMediaCommand extends Command
$this->ignored++; $this->ignored++;
} elseif ($result === FileSynchronizer::SYNC_RESULT_BAD_FILE) { } elseif ($result === FileSynchronizer::SYNC_RESULT_BAD_FILE) {
if ($this->option('verbose')) { if ($this->option('verbose')) {
$this->error(PHP_EOL . "'$name' is not a valid media file: ".$reason); $this->error(PHP_EOL."'$name' is not a valid media file: ".$reason);
} }
$this->invalid++; $this->invalid++;

View file

@ -5,6 +5,8 @@ namespace App\Services;
interface ApiConsumerInterface interface ApiConsumerInterface
{ {
public function getEndpoint(): string; public function getEndpoint(): string;
public function getKey(): ?string; public function getKey(): ?string;
public function getSecret(): ?string; public function getSecret(): ?string;
} }

View file

@ -9,8 +9,8 @@ use App\Repositories\SongRepository;
use Exception; use Exception;
use getID3; use getID3;
use getid3_lib; use getid3_lib;
use InvalidArgumentException;
use Illuminate\Contracts\Cache\Repository as Cache; use Illuminate\Contracts\Cache\Repository as Cache;
use InvalidArgumentException;
use SplFileInfo; use SplFileInfo;
use Symfony\Component\Finder\Finder; use Symfony\Component\Finder\Finder;
@ -69,8 +69,7 @@ class FileSynchronizer
SongRepository $songRepository, SongRepository $songRepository,
Cache $cache, Cache $cache,
Finder $finder Finder $finder
) ) {
{
$this->getID3 = $getID3; $this->getID3 = $getID3;
$this->mediaMetadataService = $mediaMetadataService; $this->mediaMetadataService = $mediaMetadataService;
$this->helperService = $helperService; $this->helperService = $helperService;
@ -179,6 +178,7 @@ class FileSynchronizer
return $props; return $props;
} }
/** /**
* Sync the song with all available media info against the database. * Sync the song with all available media info against the database.
* *
@ -289,7 +289,7 @@ class FileSynchronizer
private function getCoverFileUnderSameDirectory(): ?string private function getCoverFileUnderSameDirectory(): ?string
{ {
// As directory scanning can be expensive, we cache and reuse the result. // As directory scanning can be expensive, we cache and reuse the result.
return $this->cache->remember(md5($this->filePath . '_cover'), 24 * 60, function (): ?string { 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() $this->finder->create()
->depth(0) ->depth(0)
@ -312,7 +312,6 @@ class FileSynchronizer
}); });
} }
/** /**
* Determine if the file is new (its Song record can't be found in the database). * Determine if the file is new (its Song record can't be found in the database).
*/ */

View file

@ -7,7 +7,6 @@ use App\Events\LibraryChanged;
use App\Libraries\WatchRecord\WatchRecordInterface; use App\Libraries\WatchRecord\WatchRecordInterface;
use App\Models\Album; use App\Models\Album;
use App\Models\Artist; use App\Models\Artist;
use App\Models\Setting;
use App\Models\Song; use App\Models\Song;
use App\Repositories\AlbumRepository; use App\Repositories\AlbumRepository;
use App\Repositories\ArtistRepository; use App\Repositories\ArtistRepository;
@ -243,7 +242,7 @@ class MediaSyncService
} }
if (config('koel.memory_limit')) { if (config('koel.memory_limit')) {
ini_set('memory_limit', config('koel.memory_limit') . 'M'); ini_set('memory_limit', config('koel.memory_limit').'M');
} }
} }

View file

@ -19,7 +19,7 @@ class XAccelRedirectStreamer extends Streamer implements DirectStreamerInterface
header('X-Media-Root: '.Setting::get('media_path')); header('X-Media-Root: '.Setting::get('media_path'));
header("X-Accel-Redirect: /media/$relativePath"); header("X-Accel-Redirect: /media/$relativePath");
header("Content-Type: {$this->contentType}"); header("Content-Type: {$this->contentType}");
header('Content-Disposition: inline; filename="' . basename($this->song->path) . '"'); header('Content-Disposition: inline; filename="'.basename($this->song->path).'"');
exit; exit;
} }

View file

@ -18,7 +18,7 @@ class FileSynchronizerTest extends TestCase
public function testGetFileInfo() public function testGetFileInfo()
{ {
$info = $this->fileSynchronizer->setFile(__DIR__ . '/../../songs/full.mp3')->getFileInfo(); $info = $this->fileSynchronizer->setFile(__DIR__.'/../../songs/full.mp3')->getFileInfo();
$expectedData = [ $expectedData = [
'artist' => 'Koel', 'artist' => 'Koel',
@ -29,7 +29,7 @@ class FileSynchronizerTest extends TestCase
'disc' => 3, 'disc' => 3,
'lyrics' => "Foo\rbar", 'lyrics' => "Foo\rbar",
'cover' => [ 'cover' => [
'data' => file_get_contents(__DIR__ . '/../../blobs/cover.png'), 'data' => file_get_contents(__DIR__.'/../../blobs/cover.png'),
'image_mime' => 'image/png', 'image_mime' => 'image/png',
'image_width' => 512, 'image_width' => 512,
'image_height' => 512, 'image_height' => 512,
@ -38,8 +38,8 @@ class FileSynchronizerTest extends TestCase
'description' => '', 'description' => '',
'datalength' => 7627, 'datalength' => 7627,
], ],
'path' => __DIR__ . '/../../songs/full.mp3', 'path' => __DIR__.'/../../songs/full.mp3',
'mtime' => filemtime(__DIR__ . '/../../songs/full.mp3'), 'mtime' => filemtime(__DIR__.'/../../songs/full.mp3'),
'albumartist' => '', 'albumartist' => '',
]; ];
@ -50,7 +50,7 @@ class FileSynchronizerTest extends TestCase
/** @test */ /** @test */
public function song_without_a_title_tag_has_file_name_as_the_title() public function song_without_a_title_tag_has_file_name_as_the_title()
{ {
$this->fileSynchronizer->setFile(__DIR__ . '/../../songs/blank.mp3'); $this->fileSynchronizer->setFile(__DIR__.'/../../songs/blank.mp3');
self::assertSame('blank', $this->fileSynchronizer->getFileInfo()['title']); self::assertSame('blank', $this->fileSynchronizer->getFileInfo()['title']);
} }
} }