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\Repositories; use App\Models\Song; use App\Values\Genre; use Illumin..

Decoded Output download

<?php

namespace App\Repositories;

use App\Models\Song;
use App\Values\Genre;
use Illuminate\Support\Collection;
use Illuminate\Support\Facades\DB;

class GenreRepository
{
    /** @return Collection|array<array-key, Genre> */
    public function getAll(): Collection
    {
        return Song::query()
            ->select('genre', DB::raw('COUNT(id) AS song_count'), DB::raw('SUM(length) AS length'))
            ->groupBy('genre')
            ->orderBy('genre')
            ->get()
            ->transform(static fn (object $record): Genre => Genre::make(
                name: $record->genre ?: Genre::NO_GENRE,
                songCount: $record->song_count,
                length: $record->length
            ));
    }

    public function getOne(string $name): ?Genre
    {
        /** @var object|null $record */
        $record = Song::query()
            ->select('genre', DB::raw('COUNT(id) AS song_count'), DB::raw('SUM(length) AS length'))
            ->groupBy('genre')
            ->where('genre', $name === Genre::NO_GENRE ? '' : $name)
            ->first();

        return $record
            ? Genre::make(
                name: $record->genre ?: Genre::NO_GENRE,
                songCount: $record->song_count,
                length: $record->length
            )
            : null;
    }
}
 ?>

Did this file decode correctly?

Original Code

<?php

namespace App\Repositories;

use App\Models\Song;
use App\Values\Genre;
use Illuminate\Support\Collection;
use Illuminate\Support\Facades\DB;

class GenreRepository
{
    /** @return Collection|array<array-key, Genre> */
    public function getAll(): Collection
    {
        return Song::query()
            ->select('genre', DB::raw('COUNT(id) AS song_count'), DB::raw('SUM(length) AS length'))
            ->groupBy('genre')
            ->orderBy('genre')
            ->get()
            ->transform(static fn (object $record): Genre => Genre::make(
                name: $record->genre ?: Genre::NO_GENRE,
                songCount: $record->song_count,
                length: $record->length
            ));
    }

    public function getOne(string $name): ?Genre
    {
        /** @var object|null $record */
        $record = Song::query()
            ->select('genre', DB::raw('COUNT(id) AS song_count'), DB::raw('SUM(length) AS length'))
            ->groupBy('genre')
            ->where('genre', $name === Genre::NO_GENRE ? '' : $name)
            ->first();

        return $record
            ? Genre::make(
                name: $record->genre ?: Genre::NO_GENRE,
                songCount: $record->song_count,
                length: $record->length
            )
            : null;
    }
}

Function Calls

None

Variables

None

Stats

MD5 47de50aa5b31c7b32072b546048ba3a9
Eval Count 0
Decode Time 111 ms