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 Illuminate\Support\Facades\Route;
use League\Fractal\TransformerAbstract;
class ActivityTransformer extends TransformerAbstract
{
/**
* @return array
array<string,integer|string|null>
This check looks for the generic type array as a return type and suggests a more specific type. This type is inferred from the actual code.
array
*/
public function transform(Log $log)
$class = explode('\\', get_class($log->subject));
$subject = lower_case(end($class));
$subjects = str_plural(lower_case(end($class)));
$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.
return [
'id' => (int) $log->id,
'description' => (string) $log->description,
'subject' => ucfirst($subject).': '.($log->subject->username ?? $log->subject->name ?? $log->subject->title ?? $log->subject->slug),
'subject_route' => $route,
'properties' => (object) $log->properties,
'created_at' => (string) $log->created_at,
];
}
This check looks for the generic type
array
as a return type and suggests a more specific type. This type is inferred from the actual code.