<?php

namespace Src\Modules\Auth\Laravel;

use Src\Modules\Auth\Interfaces\Laravel\IUser;

class User implements IUser
{

    private ?string $id = null;

    private ?string $passwordHash = null;

    public function getType(): string
    {
        return explode('_', $this->id)[0];
    }

    protected ?string $rememberToken = null;

    public function load(array $data): void
    {
        $this->id = $data['id'] ?? null;
        $this->passwordHash = $data['password_hash'] ?? null;
    }

    /**
     * Get the name of the unique identifier for the user.
     *
     * @return string
     */
    public function getAuthIdentifierName()
    {
        return 'id';
    }

    public function getAuthPasswordName()
    {
        return 'passwordHash';
    }

    /**
     * Get the unique identifier for the user.
     *
     * @return mixed
     */
    public function getAuthIdentifier()
    {
        return $this->id;
    }

    /**
     * Get the password for the user.
     *
     * @return string
     */
    public function getAuthPassword()
    {
        return $this->passwordHash;
    }

    /**
     * Get the token value for the "remember me" session.
     *
     * @return string
     */
    public function getRememberToken()
    {
        return $this->rememberToken;
    }

    /**
     * Set the token value for the "remember me" session.
     *
     * @param  string  $value
     * @return void
     */
    public function setRememberToken($value)
    {
        $this->rememberToken = $value;
    }

    /**
     * Get the column name for the "remember me" token.
     *
     * @return string
     */
    public function getRememberTokenName() {}
}
