<?php


namespace App\Services\JWT\JWTPayload;


use App\Utils\Builder;

class JWTPayloadBuilder implements Builder
{
    protected $uid;
    protected $profile;
    protected $iat;
    protected $exp;
    protected $permissions;

    public function setUid(int $uid): JWTPayloadBuilder
    {
        $this->uid = $uid;
        return $this;
    }

    public function setProfile(int $profile): JWTPayloadBuilder
    {
        $this->profile = $profile;
        return $this;
    }

    public function setIat(string $iat): JWTPayloadBuilder
    {
        $this->iat = $iat;
        return $this;
    }

    public function setExp(string $exp): JWTPayloadBuilder
    {
        $this->exp = $exp;
        return $this;
    }

    /**
     * @param mixed $permissions
     * @return JWTPayloadBuilder
     */
    public function setPermissions(array $permissions): JWTPayloadBuilder
    {
        $this->permissions = $permissions;
        return $this;
    }

    public function build() : JWTPayload
    {
        $jwt_payload = new JWTPayload();
        $jwt_payload->setuid($this->uid);
        $jwt_payload->setprofile($this->profile);
        $jwt_payload->setiat($this->iat);
        $jwt_payload->setexp($this->exp);
        $jwt_payload->setPermissions($this->permissions ?? []);
        return $jwt_payload;
    }


}
