<?php
namespace App\Entity;
use App\Repository\ApiDetailsRepository;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
#[ORM\Entity(repositoryClass: ApiDetailsRepository::class)]
class ApiDetails
{
#[ORM\Id]
#[ORM\GeneratedValue]
#[ORM\Column(type: 'integer')]
private $id;
#[ORM\Column(type: 'string', length: 255)]
private $clientId;
#[ORM\Column(type: 'string', length: 255)]
private $clientSecret;
#[ORM\Column(type: 'datetime')]
private $modified;
#[ORM\Column(type: 'datetime')]
private $created;
#[ORM\OneToMany(targetEntity: RefreshTokens::class, mappedBy: 'api')]
private $refreshTokens;
#[ORM\OneToOne(targetEntity: Distributors::class, inversedBy: 'api', cascade: ['persist', 'remove'])]
private $distributor;
#[ORM\Column(type: 'string', length: 255)]
private $organizationId;
#[ORM\ManyToOne(targetEntity: Api::class, inversedBy: 'apiDetails')]
private $api;
public function __construct()
{
$this->setModified(new \DateTime());
if ($this->getCreated() == null) {
$this->setCreated(new \DateTime());
}
$this->refreshTokens = new ArrayCollection();
}
public function getId(): ?int
{
return $this->id;
}
public function getClientId(): ?string
{
return $this->clientId;
}
public function setClientId(string $clientId): self
{
$this->clientId = $clientId;
return $this;
}
public function getClientSecret(): ?string
{
return $this->clientSecret;
}
public function setClientSecret(string $clientSecret): self
{
$this->clientSecret = $clientSecret;
return $this;
}
public function getModified(): ?\DateTimeInterface
{
return $this->modified;
}
public function setModified(\DateTimeInterface $modified): self
{
$this->modified = $modified;
return $this;
}
public function getCreated(): ?\DateTimeInterface
{
return $this->created;
}
public function setCreated(\DateTimeInterface $created): self
{
$this->created = $created;
return $this;
}
/**
* @return Collection<int, RefreshTokens>
*/
public function getRefreshTokens(): Collection
{
return $this->refreshTokens;
}
public function addRefreshToken(RefreshTokens $refreshToken): self
{
if (!$this->refreshTokens->contains($refreshToken)) {
$this->refreshTokens[] = $refreshToken;
$refreshToken->setApiDetails($this);
}
return $this;
}
public function removeRefreshToken(RefreshTokens $refreshToken): self
{
if ($this->refreshTokens->removeElement($refreshToken)) {
// set the owning side to null (unless already changed)
if ($refreshToken->getApiDetails() === $this) {
$refreshToken->setApiDetails(null);
}
}
return $this;
}
public function getDistributor(): ?Distributors
{
return $this->distributor;
}
public function setDistributor(Distributors $distributor): self
{
$this->distributor = $distributor;
return $this;
}
public function getOrganizationId(): ?string
{
return $this->organizationId;
}
public function setOrganizationId(string $organizationId): self
{
$this->organizationId = $organizationId;
return $this;
}
public function getApi(): ?Api
{
return $this->api;
}
public function setApi(?Api $api): self
{
$this->api = $api;
return $this;
}
}