File tree Expand file tree Collapse file tree 3 files changed +4
-30
lines changed
Expand file tree Collapse file tree 3 files changed +4
-30
lines changed Original file line number Diff line number Diff line change 88
99class ListUsersAction extends UserAction
1010{
11- /**
12- * {@inheritdoc}
13- */
1411 protected function action (): Response
1512 {
1613 $ users = $ this ->userRepository ->findAll ();
Original file line number Diff line number Diff line change @@ -15,11 +15,6 @@ final class UserCreator
1515
1616 private UserCreatorRepository $ repository ;
1717
18- /**
19- * The constructor.
20- *
21- * @param UserCreatorRepository $repository The repository
22- */
2318 public function __construct (UserCreatorRepository $ repository )
2419 {
2520 $ this ->repository = $ repository ;
@@ -34,27 +29,13 @@ public function __construct(UserCreatorRepository $repository)
3429 */
3530 public function createUser (array $ data ): int
3631 {
37- // Input validation
3832 $ this ->validateNewUser ($ data );
3933
40- // Insert user
4134 $ userId = $ this ->repository ->insertUser ($ data );
4235
43- // Logging here: User created successfully
44- //$this->logger->info(sprintf('User created successfully: %s', $userId));
45-
4636 return $ userId ;
4737 }
4838
49- /**
50- * Input validation.
51- *
52- * @param array $data The form data
53- *
54- * @return void
55- * @throws ValidationException
56- *
57- */
5839 private function validateNewUser (array $ data ): void
5940 {
6041 $ validator = new Validator ($ data );
Original file line number Diff line number Diff line change @@ -20,24 +20,20 @@ public function __construct(UserReaderRepository $repository)
2020 /**
2121 * Read a user by the given user id.
2222 *
23- * @param int $userId The user id
24- *
25- * @throws ValidationException
23+ * @param int|null $userId The user id
2624 *
2725 * @return UserReaderResult The user data
26+ *
27+ * @throws ValidationException
2828 */
29- public function getUserDetails (int $ userId ): UserReaderResult
29+ public function getUserDetails (? int $ userId ): UserReaderResult
3030 {
31- // Input validation
3231 if (empty ($ userId )) {
3332 throw new ValidationException ('User ID required ' );
3433 }
3534
3635 $ userRow = $ this ->repository ->getUserById ($ userId );
3736
38- // Optional: Do something complex here...
39-
40- // Map array to data object
4137 $ user = new UserReaderResult ();
4238 $ user ->id = (int )$ userRow ['id ' ];
4339 $ user ->username = (string )$ userRow ['username ' ];
You can’t perform that action at this time.
0 commit comments