<?php
    namespace Workbloom\Component\Auth\v0\DTO;

    class UsuarioDTO {
        private ?int $id = null;
        private ?string $uuid = null;
        private ?int $status_id = null;
        private ?int $is_root = 0;
        private ?string $nome_completo = null;
        private ?string $nome_usuario = null;
        private ?string $email = null;
        private ?string $senha_hash = null;
        private ?int $need_update_password = 1;
        private ?int $days_to_expire_password = 60;
        private ?string $last_password_update = null;
        private ?string $created_at = null;
        private ?string $updated_at = null;
        private ?string $deleted_at = null;

        /**
         * Construtor do DTO.
         *
         * Permite inicializar os atributos do objeto a partir de um array associativo.
         *
         * @param array<string, mixed> $data Array associativo opcional para popular os atributos.
         */
        public function __construct(array $data = []) {
            if (!empty($data)) {
                $this->fromArray(data: $data);
            }
        }

        /**
         * Popula o DTO a partir de um array.
         *
         * @param array<string, mixed> $data
         * @return void
         */
        public function fromArray(array $data): void {
            $this->id = $data['id'] ?? $this->id;
            $this->uuid = $data['uuid'] ?? $this->uuid;
            $this->status_id = $data['status_id'] ?? $this->status_id;
            $this->is_root = $data['is_root'] ?? $this->is_root;
            $this->nome_completo = $data['nome_completo'] ?? $this->nome_completo;
            $this->nome_usuario = $data['nome_usuario'] ?? $this->nome_usuario;
            $this->email = $data['email'] ?? $this->email;
            $this->senha_hash = $data['senha_hash'] ?? $this->senha_hash;
            $this->need_update_password = $data['need_update_password'] ?? $this->need_update_password;
            $this->days_to_expire_password = $data['days_to_expire_password'] ?? $this->days_to_expire_password;
            $this->last_password_update = $data['last_password_update'] ?? $this->last_password_update;
            $this->created_at = $data['created_at'] ?? $this->created_at;
            $this->updated_at = $data['updated_at'] ?? $this->updated_at;
            $this->deleted_at = $data['deleted_at'] ?? $this->deleted_at;
        }

        /**
         * Converte o DTO para um array associativo.
         *
         * @return array<string, mixed>
         */
        public function toArray(): array {
            return [
                'id' => $this->id,
                'uuid' => $this->uuid,
                'status_id' => $this->status_id,
                'is_root' => $this->is_root,
                'nome_completo' => $this->nome_completo,
                'nome_usuario' => $this->nome_usuario,
                'email' => $this->email,
                'senha_hash' => $this->senha_hash,
                'need_update_password' => $this->need_update_password,
                'days_to_expire_password' => $this->days_to_expire_password,
                'last_password_update' => $this->last_password_update,
                'created_at' => $this->created_at,
                'updated_at' => $this->updated_at,
                'deleted_at' => $this->deleted_at,
            ];
        }

        public function getId(): ?int {
            return $this->id;
        }
        public function setId(?int $id): void {
            $this->id = $id;
        }

        public function getUuid(): ?string {
            return $this->uuid;
        }
        public function setUuid(?string $uuid): void {
            $this->uuid = $uuid;
        }

        public function getStatusId(): ?int {
            return $this->status_id;
        }
        public function setStatusId(?int $status_id): void {
            $this->status_id = $status_id;
        }

        public function getIsRoot(): ?int {
            return $this->is_root;
        }
        public function setIsRoot(?int $is_root): void {
            $this->is_root = $is_root;
        }

        public function getNomeCompleto(): ?string {
            return $this->nome_completo;
        }
        public function setNomeCompleto(?string $nome_completo): void {
            $this->nome_completo = $nome_completo;
        }

        public function getNomeUsuario(): ?string {
            return $this->nome_usuario;
        }
        public function setNomeUsuario(?string $nome_usuario): void {
            $this->nome_usuario = $nome_usuario;
        }

        public function getEmail(): ?string {
            return $this->email;
        }
        public function setEmail(?string $email): void {
            $this->email = $email;
        }

        public function getSenhaHash(): ?string {
            return $this->senha_hash;
        }
        public function setSenhaHash(?string $senha_hash): void {
            $this->senha_hash = $senha_hash;
        }

        public function getNeedUpdatePassword(): ?int {
            return $this->need_update_password;
        }
        public function setNeedUpdatePassword(?int $need_update_password): void {
            $this->need_update_password = $need_update_password;
        }

        public function getDaysToExpirePassword(): ?int {
            return $this->days_to_expire_password;
        }
        public function setDaysToExpirePassword(?int $days_to_expire_password): void {
            $this->days_to_expire_password = $days_to_expire_password;
        }

        public function getLastPasswordUpdate(): ?string {
            return $this->last_password_update;
        }
        public function setLastPasswordUpdate(?string $last_password_update): void {
            $this->last_password_update = $last_password_update;
        }

        public function getCreatedAt(): ?string {
            return $this->created_at;
        }
        public function setCreatedAt(?string $created_at): void {
            $this->created_at = $created_at;
        }

        public function getUpdatedAt(): ?string {
            return $this->updated_at;
        }
        public function setUpdatedAt(?string $updated_at): void {
            $this->updated_at = $updated_at;
        }

        public function getDeletedAt(): ?string {
            return $this->deleted_at;
        }
        public function setDeletedAt(?string $deleted_at): void {
            $this->deleted_at = $deleted_at;
        }
    }