public function patchMap(): array
    {
        $auth = $this->auth;
        return [
            ['PATCH', '/User/[i:id]', function (int $id = null, array $request) use ($auth) {
                if (isset($id) === false) {
                    throw new \InvalidArgumentException("No user found");
                }
                if ($auth->details === false || ($auth->details->id != $id && $auth->details->role_id != 1)) {
                    return [
                        "headers" => [
                            [
                                'X-PHP-Response-Code: 401',
                                true,
                                401
                            ]
                        ],
                        "response" => "Not logged in with proper credentials"
                    ];
                }
                $user = Model\User::find($id);
                if ($user === null) {
                    throw new \DomainException("No user found");
                }
                $validator = new \Valitron\Validator($request);
                $validator->rule('optional', ['name', 'email', 'avatar', 'description', 'role_id']);
                $validator->rule(function ($field, $value, array $params, array $fields) {
                    return is_string($value);
                }, ['name', 'description'])->message("{field} must be a string");
                $validator->rule('email', 'email');
                $validator->rule(function ($field, $value, array $params, array $fields) {
                    return file_exists(rtrim(public_path(), '/') . $value) || (filter_var($value, FILTER_VALIDATE_URL) !== false);
                }, 'avatar')->message('{field} must be an external link or a local file path');
                $validator->rule(function ($field, $value, $params, $fields) {
                    $role = Model\Role::find($value);
                    if ($role === null) {
                        return false;
                    }
                    return true;
                }, "role_id")->message("{field} must be a valid role");
                if ($validator->validate() === false) {
                    return [
                        "headers" => [
                            [
                                'X-PHP-Response-Code: 422',
                                true,
                                422
                            ]
                        ],
                        "response" => $validator->errors()
                    ];
                }
                if (isset($request['name']) === true) {
                    $user->name = ucwords($request['name']);
                }
                if (isset($request['email']) === true) {
                    $user->email = $request['email'];
                }
                if (isset($request['avatar']) === true) {
                    $user->avatar = $request['avatar'];
                }
                if (isset($request['description']) === true) {
                    $user->description = $request['description'];
                }
                if (isset($request['role_id']) === true) {
                    $user->role_id = $request['role_id'];
                }
                $user->save();
                return [
                    "headers" => [
                        [
                            'X-PHP-Response-Code: 200',
                            true,
                            200
                        ]
                    ],
                    "response" => true
                ];
            }],
            ['PATCH', '/User/password/[i:id]', function (int $id = null, array $request) use ($auth) {
                if (isset($id) === false) {
                    throw new \InvalidArgumentException("No user found");
                }
                if ($auth->details === false || $auth->details->id != $id) {
                    return [
                        "headers" => [
                            [
                                'X-PHP-Response-Code: 401',
                                true,
                                401
                            ]
                        ],
                        "response" => "Not logged in with proper credentials"
                    ];
                }
                $user = Model\User::find($id);
                if ($user === null) {
                    throw new \DomainException("No user found");
                }
                $validator = new \Valitron\Validator($request);
                $validator->rule('required', ['password', 'confirm_password']);
                $validator->rule(function ($field, $value, array $params, array $fields) {
                    return is_string($value);
                }, ['password', 'confirm_password'])->message("{field} must be a string");
                $validator->rule('equals', 'confirm_password', 'password');
                $validator->rule('lengthBetween', 'password', 8, 80);
                $validator->rule('notIn', 'password', [$user->username, $user->email, $user->name, $user->description, $user->avatar]);
                if ($validator->validate() === false) {
                    return [
                        "headers" => [
                            [
                                'X-PHP-Response-Code: 422',
                                true,
                                422
                            ]
                        ],
                        "response" => $validator->errors()
                    ];
                }
                $user->pass = $request['password'];
                $user->save();
                return [
                    "headers" => [
                        [
                            'X-PHP-Response-Code: 200',
                            true,
                            200
                        ]
                    ],
                    "response" => true
                ];
            }]
        ];
    }
public function patchMap(): array
    {
        $auth = $this->auth;
        return [
            ['PATCH', '/User/[i:id]', function (int $id = null, array $request) use ($auth) {
                if (isset($id) === false) {
                    throw new \InvalidArgumentException("No user found");
                }
                if ($auth->details === false || ($auth->details->id != $id && $auth->details->role_id != 1)) {
                    return [
                        "headers" => [
                            [
                                'X-PHP-Response-Code: 401',
                                true,
                                401
                            ]
                        ],
                        "response" => "Not logged in with proper credentials"
                    ];
                }
                $user = Model\User::find($id);
                if ($user === null) {
                    throw new \DomainException("No user found");
                }
                $validator = new \Valitron\Validator($request);
                $validator->rule('optional', ['name', 'email', 'avatar', 'description', 'role_id']);
                $validator->rule(function ($field, $value, array $params, array $fields) {
                    return is_string($value);
                }, ['name', 'description'])->message("{field} must be a string");
                $validator->rule('email', 'email');
                $validator->rule(function ($field, $value, array $params, array $fields) {
                    return file_exists(rtrim(public_path(), '/') . $value) || (filter_var($value, FILTER_VALIDATE_URL) !== false);
                }, 'avatar')->message('{field} must be an external link or a local file path');
                $validator->rule(function ($field, $value, $params, $fields) {
                    $role = Model\Role::find($value);
                    if ($role === null) {
                        return false;
                    }
                    return true;
                }, "role_id")->message("{field} must be a valid role");
                if ($validator->validate() === false) {
                    return [
                        "headers" => [
                            [
                                'X-PHP-Response-Code: 422',
                                true,
                                422
                            ]
                        ],
                        "response" => $validator->errors()
                    ];
                }
                if (isset($request['name']) === true) {
                    $user->name = ucwords($request['name']);
                }
                if (isset($request['email']) === true) {
                    $user->email = $request['email'];
                }
                if (isset($request['avatar']) === true) {
                    $user->avatar = $request['avatar'];
                }
                if (isset($request['description']) === true) {
                    $user->description = $request['description'];
                }
                if (isset($request['role_id']) === true) {
                    $user->role_id = $request['role_id'];
                }
                $user->save();
                return [
                    "headers" => [
                        [
                            'X-PHP-Response-Code: 200',
                            true,
                            200
                        ]
                    ],
                    "response" => true
                ];
            }],
            ['PATCH', '/User/password/[i:id]', function (int $id = null, array $request) use ($auth) {
                if (isset($id) === false) {
                    throw new \InvalidArgumentException("No user found");
                }
                if ($auth->details === false || $auth->details->id != $id) {
                    return [
                        "headers" => [
                            [
                                'X-PHP-Response-Code: 401',
                                true,
                                401
                            ]
                        ],
                        "response" => "Not logged in with proper credentials"
                    ];
                }
                $user = Model\User::find($id);
                if ($user === null) {
                    throw new \DomainException("No user found");
                }
                $validator = new \Valitron\Validator($request);
                $validator->rule('required', ['password', 'confirm_password']);
                $validator->rule(function ($field, $value, array $params, array $fields) {
                    return is_string($value);
                }, ['password', 'confirm_password'])->message("{field} must be a string");
                $validator->rule('equals', 'confirm_password', 'password');
                $validator->rule('lengthBetween', 'password', 8, 80);
                $validator->rule('notIn', 'password', [$user->username, $user->email, $user->name, $user->description, $user->avatar]);
                if ($validator->validate() === false) {
                    return [
                        "headers" => [
                            [
                                'X-PHP-Response-Code: 422',
                                true,
                                422
                            ]
                        ],
                        "response" => $validator->errors()
                    ];
                }
                $user->pass = $request['password'];
                $user->save();
                return [
                    "headers" => [
                        [
                            'X-PHP-Response-Code: 200',
                            true,
                            200
                        ]
                    ],
                    "response" => true
                ];
            }]
        ];
    }
Returns the request map for PATCH requests

@return array