<?php
namespace App\Entity\App;
use App\Repository\App\AppRepository;
use Doctrine\ORM\Mapping as ORM;
use Symfony\Component\Security\Core\User\UserInterface;
#[ORM\Entity(repositoryClass: AppRepository::class)]
class App implements UserInterface
{
#[ORM\Id]
#[ORM\GeneratedValue]
#[ORM\Column(type: 'integer')]
private ?int $id = null;
#[ORM\Column(type: 'string', length: 31)]
private ?string $label = null;
#[ORM\Column(type: 'string', length: 31, unique: true)]
private ?string $queueName = null;
#[ORM\Column(type: 'string', length: 36, unique: true)]
private ?string $secret = null;
#[ORM\Column(type: 'string', length: 255)]
private ?string $url = null;
// #[ORM\Column(type: 'string', length: 255)]
// private ?string $baseUrl = null;
public function getId(): ?int
{
return $this->id;
}
public function getLabel(): ?string
{
return $this->label;
}
public function setLabel(string $label): static
{
$this->label = $label;
return $this;
}
public function getQueueName(): ?string
{
return $this->queueName;
}
public function setQueueName(?string $queueName): static
{
$this->queueName = $queueName;
return $this;
}
public function getSecret(): ?string
{
return $this->secret;
}
public function setSecret(string $secret): static
{
$this->secret = $secret;
return $this;
}
public function getRoles(): array
{
return [
'ROLE_USER',
];
}
public function getPassword(): ?string
{
return null;
}
public function getSalt(): void
{
}
public function eraseCredentials(): void
{
}
public function getUserIdentifier(): string
{
return (string) $this->getLabel();
}
public function getUsername(): string
{
return $this->getUsername();
}
public function getUrl(): ?string
{
return rtrim($this->url, '/').'/';
}
public function setUrl(?string $url): static
{
$this->url = rtrim($url, '/').'/';
return $this;
}
public function getScheme(): ?string
{
if (null === $url = $this->getUrl()) {
return null;
}
return parse_url($url, PHP_URL_SCHEME) ?? 'http';
}
public function getPort(): ?int
{
if (null === $url = $this->getUrl()) {
return null;
}
if (null === $port = parse_url($url, PHP_URL_PORT)) {
$port = ('https' === $this->getScheme()) ? 443 : 80;
}
return $port;
}
public function getHost(): ?string
{
if (null === $url = $this->getUrl()) {
return null;
}
return parse_url($url, PHP_URL_HOST) ?? null;
}
public function getBaseUri(): ?string
{
if (null === $url = $this->getUrl()) {
return null;
}
$url = rtrim($url, '/');
if (str_contains($url, '/core')) {
return str_replace('/core', '', $url);
}
return $url;
}
}