diff --git a/app/DTOs/Auth/AuthDTO.php b/app/DTOs/Auth/AuthDTO.php index 7d9c2c4..dc318c8 100644 --- a/app/DTOs/Auth/AuthDTO.php +++ b/app/DTOs/Auth/AuthDTO.php @@ -10,5 +10,4 @@ abstract class AuthDTO extends CommonDTO { parent::__construct(); } - abstract public function toArray(); } diff --git a/app/DTOs/Auth/GoogleDTO.php b/app/DTOs/Auth/GoogleDTO.php index 152cd04..b605b19 100644 --- a/app/DTOs/Auth/GoogleDTO.php +++ b/app/DTOs/Auth/GoogleDTO.php @@ -15,11 +15,4 @@ class GoogleDTO extends AuthDTO } } } - - public function toArray(): array - { - return [ - 'access_code' => $this->access_code, - ]; - } } diff --git a/app/DTOs/Auth/LocalDTO.php b/app/DTOs/Auth/LocalDTO.php index f5db587..6477e4d 100644 --- a/app/DTOs/Auth/LocalDTO.php +++ b/app/DTOs/Auth/LocalDTO.php @@ -16,12 +16,4 @@ class LocalDTO extends AuthDTO } } } - - public function toArray(): array - { - return [ - 'id' => $this->id, - 'passwd' => $this->passwd, - ]; - } } diff --git a/app/DTOs/CollectorDTO.php b/app/DTOs/CollectorDTO.php index ab3cd1e..1fa049a 100644 --- a/app/DTOs/CollectorDTO.php +++ b/app/DTOs/CollectorDTO.php @@ -20,16 +20,4 @@ class CollectorDTO extends CommonDTO } } } - - public function toArray(): array - { - return [ - 'uid' => $this->uid, - 'trafficinfo_uid' => $this->trafficinfo_uid, - 'in' => $this->in, - 'out' => $this->out, - 'raw_in' => $this->raw_in, - 'raw_out' => $this->raw_out, - ]; - } } diff --git a/app/DTOs/CommonDTO.php b/app/DTOs/CommonDTO.php index 9d4eeca..ffed426 100644 --- a/app/DTOs/CommonDTO.php +++ b/app/DTOs/CommonDTO.php @@ -18,4 +18,10 @@ abstract class CommonDTO "Undefined property or method: " . static::class . "::{$name}" ); } + + final public function toArray(): array + { + // $this가 가진 모든 public 프로퍼티와 그 값을 배열로 반환합니다. + return get_object_vars($this); + } } diff --git a/app/DTOs/MylogDTO.php b/app/DTOs/MylogDTO.php index 4df4a32..5837b16 100644 --- a/app/DTOs/MylogDTO.php +++ b/app/DTOs/MylogDTO.php @@ -19,15 +19,4 @@ class MylogDTO extends CommonDTO } } } - - public function toArray(): array - { - return [ - 'uid' => $this->uid, - 'user_uid' => $this->user_uid, - 'title' => $this->title, - 'content' => $this->content, - 'status' => $this->status, - ]; - } } diff --git a/app/DTOs/TrafficDTO.php b/app/DTOs/TrafficDTO.php index 4fe0354..fea5ba9 100644 --- a/app/DTOs/TrafficDTO.php +++ b/app/DTOs/TrafficDTO.php @@ -22,18 +22,4 @@ class TrafficDTO extends CommonDTO } } } - - public function toArray(): array - { - return [ - 'uid' => $this->uid, - 'client' => $this->client, - 'server' => $this->server, - 'server_ip' => $this->server_ip, - 'switch' => $this->switch, - 'ip' => $this->ip, - 'interface' => $this->interface, - 'status' => $this->status, - ]; - } } diff --git a/app/DTOs/UserDTO.php b/app/DTOs/UserDTO.php index 3471668..16247be 100644 --- a/app/DTOs/UserDTO.php +++ b/app/DTOs/UserDTO.php @@ -36,19 +36,4 @@ class UserDTO extends CommonDTO } return parent::__get($name); } - - public function toArray(): array - { - return [ - 'uid' => $this->uid, - 'id' => $this->id, - 'passwd' => $this->passwd, - 'confirmpassword' => $this->confirmpassword, - 'name' => $this->name, - 'email' => $this->email, - 'mobile' => $this->mobile, - 'role' => $this->role, - 'status' => $this->status, - ]; - } }