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\Exceptions\UserProspectUpdateDeniedException; use ..
Decoded Output download
<?php
namespace App\Services;
use App\Exceptions\UserProspectUpdateDeniedException;
use App\Models\User;
use Illuminate\Contracts\Hashing\Hasher;
class UserService
{
public function __construct(private Hasher $hash)
{
}
public function createUser(string $name, string $email, string $plainTextPassword, bool $isAdmin): User
{
return User::query()->create([
'name' => $name,
'email' => $email,
'password' => $this->hash->make($plainTextPassword),
'is_admin' => $isAdmin,
]);
}
public function updateUser(User $user, string $name, string $email, string|null $password, bool $isAdmin): User
{
throw_if($user->is_prospect, new UserProspectUpdateDeniedException());
$data = [
'name' => $name,
'email' => $email,
'is_admin' => $isAdmin,
];
if ($password) {
$data['password'] = $this->hash->make($password);
}
$user->update($data);
return $user;
}
public function deleteUser(User $user): void
{
$user->delete();
}
}
?>
Did this file decode correctly?
Original Code
<?php
namespace App\Services;
use App\Exceptions\UserProspectUpdateDeniedException;
use App\Models\User;
use Illuminate\Contracts\Hashing\Hasher;
class UserService
{
public function __construct(private Hasher $hash)
{
}
public function createUser(string $name, string $email, string $plainTextPassword, bool $isAdmin): User
{
return User::query()->create([
'name' => $name,
'email' => $email,
'password' => $this->hash->make($plainTextPassword),
'is_admin' => $isAdmin,
]);
}
public function updateUser(User $user, string $name, string $email, string|null $password, bool $isAdmin): User
{
throw_if($user->is_prospect, new UserProspectUpdateDeniedException());
$data = [
'name' => $name,
'email' => $email,
'is_admin' => $isAdmin,
];
if ($password) {
$data['password'] = $this->hash->make($password);
}
$user->update($data);
return $user;
}
public function deleteUser(User $user): void
{
$user->delete();
}
}
Function Calls
None |
Stats
MD5 | 365b2d6ec69b8353451fc0f048c00416 |
Eval Count | 0 |
Decode Time | 100 ms |