Find this useful? Enter your email to receive occasional updates for securing PHP code.
Signing you up...
Thank you for signing up!
PHP Decode
<?php namespace App\Services; use App\Models\Album; use App\Models\Artist; use Illuminat..
Decoded Output download
<?php
namespace App\Services;
use App\Models\Album;
use App\Models\Artist;
use Illuminate\Database\Eloquent\Collection;
use Illuminate\Support\Facades\DB;
class LibraryManager
{
/**
* @return array{
* albums: Collection<array-key, Album>,
* artists: Collection<array-key, Artist>,
* }
*/
public function prune(bool $dryRun = false): array
{
return DB::transaction(static function () use ($dryRun): array {
$albumQuery = Album::query()
->leftJoin('songs', 'songs.album_id', '=', 'albums.id')
->whereNull('songs.album_id')
->whereNotIn('albums.id', [Album::UNKNOWN_ID]);
$artistQuery = Artist::query()
->leftJoin('songs', 'songs.artist_id', '=', 'artists.id')
->leftJoin('albums', 'albums.artist_id', '=', 'artists.id')
->whereNull('songs.artist_id')
->whereNull('albums.artist_id')
->whereNotIn('artists.id', [Artist::UNKNOWN_ID, Artist::VARIOUS_ID]);
$results = [
'albums' => $albumQuery->get('albums.*'),
'artists' => $artistQuery->get('artists.*'),
];
if (!$dryRun) {
$albumQuery->delete();
$artistQuery->delete();
}
return $results;
});
}
}
?>
Did this file decode correctly?
Original Code
<?php
namespace App\Services;
use App\Models\Album;
use App\Models\Artist;
use Illuminate\Database\Eloquent\Collection;
use Illuminate\Support\Facades\DB;
class LibraryManager
{
/**
* @return array{
* albums: Collection<array-key, Album>,
* artists: Collection<array-key, Artist>,
* }
*/
public function prune(bool $dryRun = false): array
{
return DB::transaction(static function () use ($dryRun): array {
$albumQuery = Album::query()
->leftJoin('songs', 'songs.album_id', '=', 'albums.id')
->whereNull('songs.album_id')
->whereNotIn('albums.id', [Album::UNKNOWN_ID]);
$artistQuery = Artist::query()
->leftJoin('songs', 'songs.artist_id', '=', 'artists.id')
->leftJoin('albums', 'albums.artist_id', '=', 'artists.id')
->whereNull('songs.artist_id')
->whereNull('albums.artist_id')
->whereNotIn('artists.id', [Artist::UNKNOWN_ID, Artist::VARIOUS_ID]);
$results = [
'albums' => $albumQuery->get('albums.*'),
'artists' => $artistQuery->get('artists.*'),
];
if (!$dryRun) {
$albumQuery->delete();
$artistQuery->delete();
}
return $results;
});
}
}
Function Calls
None |
Stats
MD5 | 084dca3c12b87b40d2c4a6908c7b3f2e |
Eval Count | 0 |
Decode Time | 104 ms |