Return types
This commit is contained in:
@@ -10,7 +10,7 @@ use Khofmann\Models\User\User;
|
||||
|
||||
class Login extends Api
|
||||
{
|
||||
public function post()
|
||||
public function post(): void
|
||||
{
|
||||
$email = Input::post("email");
|
||||
if (empty($email)) throw new Exception("Missing email", 400);
|
||||
@@ -18,7 +18,7 @@ class Login extends Api
|
||||
if (empty($password)) throw new Exception("Missing password", 400);
|
||||
|
||||
try {
|
||||
return Response::json(User::logIn($email, $password));
|
||||
Response::json(User::logIn($email, $password));
|
||||
} catch (Exception $err) {
|
||||
switch ($err->getMessage()) {
|
||||
case "Failed":
|
||||
|
||||
@@ -9,9 +9,10 @@ use Khofmann\Response\Response;
|
||||
|
||||
class Logout extends Api
|
||||
{
|
||||
public function post()
|
||||
public function post(): void
|
||||
{
|
||||
$token = Request::header("token");
|
||||
return Response::json(User::getByToken($token)->logOut());
|
||||
|
||||
Response::json(User::getByToken($token)->logOut());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,7 +10,7 @@ use Khofmann\Models\User\User;
|
||||
|
||||
class Register extends Api
|
||||
{
|
||||
public function post()
|
||||
public function post(): void
|
||||
{
|
||||
$username = Input::post("username");
|
||||
if (empty($username)) throw new Exception("Missing username", 400);
|
||||
@@ -20,7 +20,7 @@ class Register extends Api
|
||||
if (empty($password)) throw new Exception("Missing password", 400);
|
||||
|
||||
try {
|
||||
return Response::json(User::create($username, $email, $password));
|
||||
Response::json(User::create($username, $email, $password));
|
||||
} catch (Exception $err) {
|
||||
switch ($err->getMessage()) {
|
||||
case "Duplicate":
|
||||
|
||||
@@ -11,10 +11,10 @@ use Khofmann\Request\Request;
|
||||
|
||||
class User extends Api
|
||||
{
|
||||
public function get($id)
|
||||
public function get($id): void
|
||||
{
|
||||
try {
|
||||
return Response::json(MUser::getByID($id));
|
||||
Response::json(MUser::getByID($id));
|
||||
} catch (Exception $err) {
|
||||
switch ($err->getMessage()) {
|
||||
case "NotFound":
|
||||
@@ -25,14 +25,14 @@ class User extends Api
|
||||
}
|
||||
}
|
||||
|
||||
public function patch($id)
|
||||
public function patch($id): void
|
||||
{
|
||||
$username = Input::patch("username");
|
||||
$password = Input::patch("password");
|
||||
$image = Input::file("image");
|
||||
|
||||
try {
|
||||
return Response::json(MUser::getByID($id)->update($username, $password, $image));
|
||||
Response::json(MUser::getByID($id)->update($username, $password, $image));
|
||||
} catch (Exception $err) {
|
||||
switch ($err->getMessage()) {
|
||||
case "NotFound":
|
||||
@@ -49,7 +49,7 @@ class User extends Api
|
||||
}
|
||||
}
|
||||
|
||||
public function patchSelf()
|
||||
public function patchSelf(): void
|
||||
{
|
||||
$token = Request::header("token");
|
||||
$username = Input::patch("username");
|
||||
@@ -57,7 +57,7 @@ class User extends Api
|
||||
$image = Input::file("image");
|
||||
|
||||
try {
|
||||
return Response::json(MUser::getByToken($token)->update($username, $password, $image));
|
||||
Response::json(MUser::getByToken($token)->update($username, $password, $image));
|
||||
} catch (Exception $err) {
|
||||
switch ($err->getMessage()) {
|
||||
case "NotFound":
|
||||
@@ -74,10 +74,10 @@ class User extends Api
|
||||
}
|
||||
}
|
||||
|
||||
public function delete($id)
|
||||
public function delete($id): void
|
||||
{
|
||||
try {
|
||||
return Response::json(MUser::getByID($id)->delete());
|
||||
Response::json(MUser::getByID($id)->delete());
|
||||
} catch (Exception $err) {
|
||||
switch ($err->getMessage()) {
|
||||
case "NotFound":
|
||||
|
||||
Reference in New Issue
Block a user