<?php

namespace Lucent\Account;


class User
{

    /**
     * @param array<string> $roles
     */
    function __construct(
        public string  $id,
        public Name    $name,
        public Email   $email,
        public array   $roles,
        public string  $createdAt,
        public string  $updatedAt,
        public ?string $loggedInAt = null,
        public ?string $mailToken = null,

    )
    {
    }


    public function isRemoved()
    {
        return in_array("removed", $this->roles);
    }

    public function safe(): array
    {
        $userData = collect(toArray($this));
        return $userData->only(["id", "name", "email", "roles", "status"])->toArray();
    }
}
