-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathReflection.php
More file actions
32 lines (23 loc) · 923 Bytes
/
Copy pathReflection.php
File metadata and controls
32 lines (23 loc) · 923 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
<?php
require_once "exception/ValidationException.php";
require_once "data/LoginRequest.php";
require_once "helper/ValidationUtil.php";
$loginRequest = new LoginRequest();
$loginRequest->username = "glh";
// ValidationUtil::validate($loginRequest);
// ValidationUtil::validateReflection($loginRequest);
// berguna banget jika kita mempunya object dengan class yang berbeda, untuk pengecekan login, order dll
// jadi cukup buat satu bisa dipakai di semua object.
// pembuktian
class RegisterUserRequest
{
public ?string $name;
public ?string $address;
public ?string $email;
}
$register = new RegisterUserRequest();
$register->name = "glh";
$register->address = "glh";
$register->email = "galihrizki@gmail.com";
// jika di test satu satu property diatas tanpa di sett atau dibuat null maka dia akan ketangkap exception, tinggal kita tangkap pakai try cath
ValidationUtil::validateReflection($register);