fix: static analytics

This commit is contained in:
Phan An 2024-03-28 10:18:14 +01:00
parent 937e902972
commit 58f62c24ed
8 changed files with 11 additions and 8 deletions

View file

@ -55,7 +55,7 @@ class SetupDropboxStorageCommand extends Command
$accessCode = $this->ask('Enter the access code');
$response = Http::asForm()
->withBasicAuth($appKey, $appSecret)
->withBasicAuth($config['DROPBOX_APP_KEY'], $config['DROPBOX_APP_SECRET'])
->post('https://api.dropboxapi.com/oauth2/token', [
'code' => $accessCode,
'grant_type' => 'authorization_code',

View file

@ -11,7 +11,7 @@ class UnsupportedSongStorageTypeException extends Exception
parent::__construct("Unsupported song storage type: $storageType");
}
public function create(string $storageType): self
public static function create(string $storageType): self
{
return new self($storageType);
}

View file

@ -15,7 +15,6 @@ use Illuminate\Http\Response;
class PlaylistCollaboratorController extends Controller
{
/** @param User $user */
public function __construct(private PlaylistCollaborationService $service, private UserRepository $userRepository)
{
}

View file

@ -63,7 +63,8 @@ class Playlist extends Model
public function songs(): BelongsToMany
{
return $this->belongsToMany(Song::class)->withTimestamps()
return $this->belongsToMany(Song::class)
->withTimestamps()
->withPivot('position')
->orderByPivot('position');
}
@ -160,7 +161,7 @@ class Playlist extends Model
public function addSongs(Collection|Song|array $songs, ?User $collaborator = null): void
{
$collaborator ??= $this->user;
$maxPosition = $this->songs()->max('position') ?? 0;
$maxPosition = $this->songs()->getQuery()->max('position') ?? 0;
if (!is_array($songs)) {
$songs = Collection::wrap($songs)->pluck('id')->all();

View file

@ -39,7 +39,7 @@ class Streamer
SongStorageTypes::LOCAL, '' => app(LocalStreamerAdapter::class),
SongStorageTypes::S3, SongStorageTypes::S3_LAMBDA => app(S3CompatibleStreamerAdapter::class),
SongStorageTypes::DROPBOX => app(DropboxStreamerAdapter::class),
default => throw UnsupportedSongStorageTypeException::make($this->song->storage),
default => throw UnsupportedSongStorageTypeException::create($this->song->storage),
};
}

View file

@ -9,7 +9,7 @@ use Throwable;
final class Equalizer implements Arrayable
{
/** @param array<int>|null $gains */
private function __construct(public ?string $name, public int $preamp, public array $gains)
private function __construct(public ?string $name, public ?int $preamp, public ?array $gains)
{
}

View file

@ -6,6 +6,7 @@ use App\Models\Album;
use App\Models\Song;
use App\Services\MediaMetadataService;
use Mockery;
use Mockery\MockInterface;
use Tests\PlusTestCase;
use function Tests\create_admin;
@ -13,6 +14,8 @@ use function Tests\create_user;
class AlbumCoverTest extends PlusTestCase
{
private MediaMetadataService|MockInterface $mediaMetadataService;
public function setUp(): void
{
parent::setUp();

View file

@ -40,7 +40,7 @@ class DropboxStorageTest extends PlusTestCase
$this->client = $this->mock(Client::class);
$this->filesystem = $this->mock(DropboxFilesystem::class);
$this->filesystem->allows('getAdapter')->andReturns(
$this->filesystem->allows('getAdapter')->andReturn(
Mockery::mock(DropboxAdapter::class, ['getClient' => $this->client])
);