|
2 | 2 | namespace PH7\ApiSimpleMenu\Service; |
3 | 3 |
|
4 | 4 | use PH7\ApiSimpleMenu\Dal\UserDal; |
5 | | -use PH7\ApiSimpleMenu\Route\Exception\NotFoundException; |
6 | 5 | use PH7\ApiSimpleMenu\Validation\Exception\InvalidValidationException; |
7 | 6 | use PH7\ApiSimpleMenu\Validation\UserValidation; |
8 | 7 | use PH7\JustHttp\StatusCode; |
9 | 8 | use PH7\PhpHttpResponseHeader\Http as HttpResponse; |
10 | 9 | use Ramsey\Uuid\Uuid; |
11 | 10 | use Respect\Validation\Validator as v; |
12 | 11 | use PH7\ApiSimpleMenu\Entity\User as UserEntity; |
13 | | -use PH7\ApiSimpleMenu\Route\Http; |
14 | 12 |
|
15 | 13 | class User |
16 | 14 | { |
17 | 15 | public const DATE_TIME_FORMAT = 'Y-m-d H:i:s'; |
18 | 16 |
|
19 | 17 | public function create(mixed $data): array|object |
20 | 18 | { |
21 | | - if (!Http::doesHttpMethodMatch(Http::POST_METHOD)) { |
22 | | - throw new NotFoundException('HTTP method is incorrect. Request not found'); |
23 | | - } |
24 | | - |
25 | 19 | $userValidation = new UserValidation($data); |
26 | 20 | if ($userValidation->isCreationSchemaValid()) { |
27 | 21 | $userUuid = Uuid::uuid4()->toString(); // assigning a UUID to the user |
@@ -55,10 +49,6 @@ public function create(mixed $data): array|object |
55 | 49 |
|
56 | 50 | public function update(mixed $postBody): array|object |
57 | 51 | { |
58 | | - if (!Http::doesHttpMethodMatch(Http::POST_METHOD)) { |
59 | | - throw new NotFoundException('HTTP method is incorrect. Request not found'); |
60 | | - } |
61 | | - |
62 | 52 | $userValidation = new UserValidation($postBody); |
63 | 53 | if ($userValidation->isUpdateSchemaValid()) { |
64 | 54 | $userUuid = $postBody->userUuid; |
@@ -123,10 +113,6 @@ public function retrieve(string $userUuid): array |
123 | 113 | */ |
124 | 114 | public function remove(mixed $data): bool |
125 | 115 | { |
126 | | - if (!Http::doesHttpMethodMatch(Http::DELETE_METHOD)) { |
127 | | - throw new NotFoundException('HTTP method is incorrect. Request not found'); |
128 | | - } |
129 | | - |
130 | 116 | $userValidation = new UserValidation($data); |
131 | 117 | if ($userValidation->isRemoveSchemaValid()) { |
132 | 118 | // Send a 204 if the user got removed |
|
0 commit comments