File tree Expand file tree Collapse file tree 3 files changed +5
-20
lines changed
Expand file tree Collapse file tree 3 files changed +5
-20
lines changed Original file line number Diff line number Diff line change @@ -15,13 +15,6 @@ class User
1515{
1616 public const DATE_TIME_FORMAT = 'Y-m-d H:i:s ' ;
1717
18- public function __construct (
19- public readonly string $ name ,
20- public readonly string $ email ,
21- public readonly string $ phone ,
22- ) {}
23-
24- // public function create(object $data): self // <- can still be valid
2518 public function create (mixed $ data ): object
2619 {
2720 // validate data
Original file line number Diff line number Diff line change 33
44$ resource = $ _REQUEST ['resource ' ] ?? null ;
55
6- switch ($ resource ) {
7- case 'user ' :
8- return require_once 'user.routes.php ' ;
9-
10- default :
11- return require_once 'main.routes.php ' ;
12- }
6+ return match ($ resource ) {
7+ 'user ' => require_once 'user.routes.php ' ,
8+ default => require_once 'main.routes.php ' ,
9+ };
Original file line number Diff line number Diff line change 77use PH7 \JustHttp \StatusCode ;
88use PH7 \PhpHttpResponseHeader \Http ;
99
10- require_once dirname (__DIR__ ) . '/Service/User.php ' ;
11-
12- // PHP 8.1 enums
1310enum UserAction: string
1411{
1512 case CREATE = 'create ' ;
@@ -26,9 +23,7 @@ public function getResponse(): string
2623 // Ternary conditional operator operator
2724 $ userId = $ _REQUEST ['id ' ] ?? null ; // using the null coalescing operator
2825
29- // TODO Remove the hard-coded values from here
30- $ user = new User ('Pierre ' , 'pierre@soria.email ' , '042634759375 ' );
31-
26+ $ user = new User ();
3227 try {
3328 $ response = match ($ this ) {
3429 self ::CREATE => $ user ->create ($ postBody ),
You can’t perform that action at this time.
0 commit comments