src/Entity/CRM/DataSource.php line 14
<?phpnamespace App\Entity\CRM;use App\Enum\DataSourceSyncStatus;use App\Enum\DataSourceType;use App\Repository\DataSourceRepository;use Doctrine\Common\Collections\ArrayCollection;use Doctrine\Common\Collections\Collection;use Doctrine\DBAL\Types\Types;use Doctrine\ORM\Mapping as ORM;#[ORM\Entity(repositoryClass: DataSourceRepository::class)]class DataSource{#[ORM\Id]#[ORM\GeneratedValue]#[ORM\Column]private ?int $id = null;#[ORM\ManyToOne(inversedBy: 'dataSources')]#[ORM\JoinColumn(nullable: true)]private ?Branch $tenant = null;#[ORM\Column(length: 255)]private ?string $name = null;#[ORM\Column(length: 16, enumType: DataSourceType::class)]private DataSourceType $type = DataSourceType::FTP;#[ORM\Column]private bool $enabled = true;#[ORM\Column(length: 255, nullable: true)]private ?string $host = null;#[ORM\Column(nullable: true)]private ?int $port = 21;#[ORM\Column(length: 255, nullable: true)]private ?string $username = null;#[ORM\Column(type: Types::TEXT, nullable: true)]private ?string $passwordEncrypted = null;#[ORM\Column(length: 255, nullable: true)]private ?string $path = null;#[ORM\Column]private bool $passive = true;#[ORM\Column(length: 255, nullable: true)]private ?string $apiUrl = null;#[ORM\Column(type: Types::TEXT, nullable: true)]private ?string $apiKeyEncrypted = null;#[ORM\Column(length: 255, nullable: true)]private ?string $localPath = null;#[ORM\Column(type: Types::DATETIME_MUTABLE, nullable: true)]private ?\DateTimeInterface $lastSyncAt = null;#[ORM\Column(length: 16, enumType: DataSourceSyncStatus::class, nullable: true)]private ?DataSourceSyncStatus $lastSyncStatus = null;#[ORM\Column(type: Types::TEXT, nullable: true)]private ?string $lastSyncError = null;#[ORM\Column(type: Types::DATETIME_MUTABLE)]private \DateTimeInterface $createdAt;#[ORM\Column(type: Types::DATETIME_MUTABLE)]private \DateTimeInterface $updatedAt;#[ORM\OneToMany(mappedBy: 'source', targetEntity: TranscriptionJob::class)]private Collection $transcriptionJobs;private ?string $plainPassword = null;private ?string $plainApiKey = null;public function __construct(){$now = new \DateTimeImmutable();$this->createdAt = $now;$this->updatedAt = $now;$this->transcriptionJobs = new ArrayCollection();}public function __toString(): string{return (string) ($this->name ?? ('Źródło #' . $this->id));}public function getId(): ?int{return $this->id;}public function getTenant(): ?Branch{return $this->tenant;}public function setTenant(?Branch $tenant): static{$this->tenant = $tenant;return $this;}public function getName(): ?string{return $this->name;}public function setName(string $name): static{$this->name = $name;return $this;}public function getType(): DataSourceType{return $this->type;}public function setType(DataSourceType $type): static{$this->type = $type;return $this;}public function isEnabled(): bool{return $this->enabled;}public function setEnabled(bool $enabled): static{$this->enabled = $enabled;return $this;}public function getHost(): ?string{return $this->host;}public function setHost(?string $host): static{$this->host = $host;return $this;}public function getPort(): ?int{return $this->port;}public function setPort(?int $port): static{$this->port = $port;return $this;}public function getUsername(): ?string{return $this->username;}public function setUsername(?string $username): static{$this->username = $username;return $this;}public function getPasswordEncrypted(): ?string{return $this->passwordEncrypted;}public function setPasswordEncrypted(?string $passwordEncrypted): static{$this->passwordEncrypted = $passwordEncrypted;return $this;}public function getPath(): ?string{return $this->path;}public function setPath(?string $path): static{$this->path = $path;return $this;}public function isPassive(): bool{return $this->passive;}public function setPassive(bool $passive): static{$this->passive = $passive;return $this;}public function getApiUrl(): ?string{return $this->apiUrl;}public function setApiUrl(?string $apiUrl): static{$this->apiUrl = $apiUrl;return $this;}public function getApiKeyEncrypted(): ?string{return $this->apiKeyEncrypted;}public function setApiKeyEncrypted(?string $apiKeyEncrypted): static{$this->apiKeyEncrypted = $apiKeyEncrypted;return $this;}public function getLocalPath(): ?string{return $this->localPath;}public function setLocalPath(?string $localPath): static{$this->localPath = $localPath;return $this;}public function getLastSyncAt(): ?\DateTimeInterface{return $this->lastSyncAt;}public function setLastSyncAt(?\DateTimeInterface $lastSyncAt): static{$this->lastSyncAt = $lastSyncAt;return $this;}public function getLastSyncStatus(): ?DataSourceSyncStatus{return $this->lastSyncStatus;}public function setLastSyncStatus(?DataSourceSyncStatus $lastSyncStatus): static{$this->lastSyncStatus = $lastSyncStatus;return $this;}public function getLastSyncError(): ?string{return $this->lastSyncError;}public function setLastSyncError(?string $lastSyncError): static{$this->lastSyncError = $lastSyncError;return $this;}public function getCreatedAt(): \DateTimeInterface{return $this->createdAt;}public function getUpdatedAt(): \DateTimeInterface{return $this->updatedAt;}public function setUpdatedAt(\DateTimeInterface $updatedAt): static{$this->updatedAt = $updatedAt;return $this;}public function touch(): static{$this->updatedAt = new \DateTimeImmutable();return $this;}public function getPlainPassword(): ?string{return $this->plainPassword;}public function setPlainPassword(?string $plainPassword): static{$this->plainPassword = $plainPassword;return $this;}public function getPlainApiKey(): ?string{return $this->plainApiKey;}public function setPlainApiKey(?string $plainApiKey): static{$this->plainApiKey = $plainApiKey;return $this;}public function getMaskedPassword(): ?string{if ($this->passwordEncrypted === null || $this->passwordEncrypted === '') {return null;}return self::maskSecret($this->plainPassword);}public function getMaskedApiKey(): ?string{if ($this->apiKeyEncrypted === null || $this->apiKeyEncrypted === '') {return null;}return self::maskSecret($this->plainApiKey);}public function hasPasswordConfigured(): bool{return $this->passwordEncrypted !== null && $this->passwordEncrypted !== '';}public function hasApiKeyConfigured(): bool{return $this->apiKeyEncrypted !== null && $this->apiKeyEncrypted !== '';}/*** @return Collection<int, TranscriptionJob>*/public function getTranscriptionJobs(): Collection{return $this->transcriptionJobs;}public function addTranscriptionJob(TranscriptionJob $transcriptionJob): static{if (!$this->transcriptionJobs->contains($transcriptionJob)) {$this->transcriptionJobs->add($transcriptionJob);$transcriptionJob->setSource($this);}return $this;}public function removeTranscriptionJob(TranscriptionJob $transcriptionJob): static{if ($this->transcriptionJobs->removeElement($transcriptionJob)) {if ($transcriptionJob->getSource() === $this) {$transcriptionJob->setSource(null);}}return $this;}private static function maskSecret(?string $plainText = null): string{if ($plainText === null || $plainText === '') {return '********';}$length = strlen($plainText);if ($length <= 4) {return str_repeat('*', $length);}return substr($plainText, 0, 2) . str_repeat('*', $length - 4) . substr($plainText, -2);}}