for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
declare(strict_types=1);
namespace Cortex\Foundation\Transformers;
use Cortex\Foundation\Models\Log;
use Rinvex\Support\Traits\Escaper;
use Illuminate\Support\Facades\Route;
use League\Fractal\TransformerAbstract;
class ActivityTransformer extends TransformerAbstract
{
use Escaper;
/**
* @return array
*/
public function transform(Log $log): array
$subject = $log->subject_type;
$subjects = str_plural($subject);
$route = Route::has("adminarea.{$subjects}.edit") ? route("adminarea.{$subjects}.edit", [$subject => $log->subject]) : null;
Overly long lines are hard to read on any screen. Most code styles therefor impose a maximum limit on the number of characters in a line.
if ($log->subject) {
$subjectName = ucfirst($subject).': '.($log->subject->username ?? $log->subject->name ?? $log->subject->name);
} else {
$subjectName = ucfirst($subject).': Not Found!';
}
return $this->escape([
'id' => (int) $log->getKey(),
'description' => (string) $log->description,
'subject' => $subjectName,
'subject_route' => $route,
'properties' => (object) $log->properties,
'created_at' => (string) $log->created_at,
]);
Overly long lines are hard to read on any screen. Most code styles therefor impose a maximum limit on the number of characters in a line.