mirror of
https://github.com/vitodeploy/vito.git
synced 2025-07-02 14:36:17 +00:00
Add phpstan level 7(#544)
This commit is contained in:
@ -5,9 +5,15 @@
|
||||
use App\Models\Project;
|
||||
use App\Models\User;
|
||||
use Illuminate\Validation\Rule;
|
||||
use Illuminate\Validation\ValidationException;
|
||||
|
||||
class UpdateProjects
|
||||
{
|
||||
/**
|
||||
* @param array<string, mixed> $input
|
||||
*
|
||||
* @throws ValidationException
|
||||
*/
|
||||
public function update(User $user, array $input): void
|
||||
{
|
||||
$this->validate($input);
|
||||
@ -20,7 +26,7 @@ public function update(User $user, array $input): void
|
||||
|
||||
$user->refresh();
|
||||
|
||||
/** @var Project $firstProject */
|
||||
/** @var ?Project $firstProject */
|
||||
$firstProject = $user->projects->first();
|
||||
if (! $user->currentProject && $firstProject) {
|
||||
$user->current_project_id = $firstProject->id;
|
||||
@ -28,11 +34,19 @@ public function update(User $user, array $input): void
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array<string, mixed> $input
|
||||
*
|
||||
* @throws ValidationException
|
||||
*/
|
||||
private function validate(array $input): void
|
||||
{
|
||||
validator($input, self::rules())->validate();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array<string, array<string>>
|
||||
*/
|
||||
public static function rules(): array
|
||||
{
|
||||
return [
|
||||
|
Reference in New Issue
Block a user