<?php
declare(strict_types=1);
namespace App\Entity;
use App\Services\Youtube\Dto\YoutubeAuthDto;
use DateTimeImmutable;
use Doctrine\ORM\Mapping\Column;
use Doctrine\ORM\Mapping\Entity;
use Doctrine\ORM\Mapping\Id;
#[Entity]
class YoutubeAuth
{
#[Id]
#[Column(type: 'string', unique: true)]
private string $id;
#[Column(type: 'string', unique: true, nullable: true)]
private ?string $channelId = null;
#[Column(type: 'string', nullable: false)]
private string $accessToken;
#[Column(type: 'string', nullable: false)]
private string $refreshToken;
#[Column(type: 'text', nullable: false)]
private string $scope;
#[Column(type: 'string', nullable: false)]
private string $tokenType;
#[Column(type: 'integer', nullable: false)]
private int $expiredIn;
#[Column(type: 'datetime_immutable', nullable: false)]
private DateTimeImmutable $createdAt;
public function __construct(
string $id,
string $accessToken,
string $refreshToken,
string $scope,
string $tokenType,
int $expiredIn,
DateTimeImmutable $createdAt,
) {
$this->id = $id;
$this->accessToken = $accessToken;
$this->refreshToken = $refreshToken;
$this->scope = $scope;
$this->tokenType = $tokenType;
$this->expiredIn = $expiredIn;
$this->createdAt = $createdAt;
}
public function getId(): string
{
return $this->id;
}
public function getChannelId(): ?string
{
return $this->channelId;
}
public function setChannelId(string $channelId): static
{
$this->channelId = $channelId;
return $this;
}
public function getAccessToken(): string
{
return $this->accessToken;
}
public function setAccessToken(string $accessToken): static
{
$this->accessToken = $accessToken;
return $this;
}
public function getRefreshToken(): string
{
return $this->refreshToken;
}
public function setRefreshToken(string $refreshToken): static
{
$this->refreshToken = $refreshToken;
return $this;
}
public function getScope(): string
{
return $this->scope;
}
public function setScope(string $scope): static
{
$this->scope = $scope;
return $this;
}
public function getTokenType(): string
{
return $this->tokenType;
}
public function setTokenType(string $tokenType): static
{
$this->tokenType = $tokenType;
return $this;
}
public function getExpiredIn(): int
{
return $this->expiredIn;
}
public function setExpiredIn(int $expiredIn): static
{
$this->expiredIn = $expiredIn;
return $this;
}
public function getCreatedAt(): DateTimeImmutable
{
return $this->createdAt;
}
public function setCreatedAt(DateTimeImmutable $createdAt): static
{
$this->createdAt = $createdAt;
return $this;
}
public function toDto(): YoutubeAuthDto
{
return new YoutubeAuthDto(
$this->getId(),
$this->getAccessToken(),
);
}
}