<?php
namespace App\Entity\Channel\PositioningTest\Attempt;
use App\Entity\Channel\PositioningTest\PositioningTest;
use App\Entity\ChannelUserData\ChannelUserData;
use App\Entity\Common\Contact;
use App\Enum\Channel\PositioningTest\StatusEnum;
use App\Repository\Channel\PositioningTest\Attempt\AttemptRepository;
use DateTime;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
use DrosalysWeb\ObjectExtensions\Blame\Model\BlameInterface;
use DrosalysWeb\ObjectExtensions\Blame\Model\BlameTrait;
use DrosalysWeb\ObjectExtensions\Timestamp\Model\TimestampInterface;
use DrosalysWeb\ObjectExtensions\Timestamp\Model\TimestampTrait;
use Nellapp\Bundle\SDKBundle\Google\Entity\GoogleExportableInterface;
use Nellapp\Bundle\SDKBundle\Google\Entity\GoogleExportedData\GoogleExportedData;
#[
ORM\Entity(repositoryClass: AttemptRepository::class),
ORM\Table(name: 'channel_positioning_test_attempts'),
]
class Attempt implements TimestampInterface, BlameInterface, GoogleExportableInterface
{
use TimestampTrait;
use BlameTrait;
#[ORM\Id]
#[ORM\GeneratedValue]
#[ORM\Column(type: 'integer')]
private ?int $id = null;
#[ORM\Column(type: 'string', length: 64, unique: true)]
private ?string $accessToken;
#[ORM\Column(type: 'datetime', nullable: true)]
private ?DateTime $startedAt = null;
#[ORM\Column(type: 'datetime', nullable: true)]
private ?DateTime $endedAt = null;
#[ORM\Column(type: 'integer')]
private ?int $time = 0;
#[ORM\Column(type: 'string', nullable: true, options: ['default' => StatusEnum::WAITING])]
private ?string $status = StatusEnum::WAITING;
#[ORM\Column(type: 'string', nullable: true, options: ['default' => null])]
private ?string $result = null;
#[ORM\Column(type: 'boolean', nullable: false)]
private bool $emailConfirmed = false;
#[ORM\Column(type: 'boolean', nullable: true)]
private ?bool $isInterestedInWorkStudy = null;
#[ORM\Column(type: 'boolean', nullable: true)]
private ?bool $isInterestedByFindWorkStudyTrainee = null;
#[ORM\ManyToOne(targetEntity: Contact::class, cascade: ['persist'])]
#[ORM\JoinColumn(nullable: false, onDelete: 'CASCADE')]
private ?Contact $prospect = null;
#[ORM\ManyToOne(targetEntity: ChannelUserData::class, cascade: ['persist'], inversedBy: 'positioningTestAttempts')]
#[ORM\JoinColumn(nullable: true, onDelete: 'SET NULL')]
private ?ChannelUserData $channelUserData = null;
#[ORM\ManyToOne(targetEntity: PositioningTest::class, inversedBy: 'attempts')]
#[ORM\JoinColumn(nullable: true, onDelete: 'SET NULL')]
private ?PositioningTest $positioningTest = null;
#[ORM\OneToMany(mappedBy: 'attempt', targetEntity: AttemptBlock::class, cascade: ['persist', 'remove'], orphanRemoval: true)]
#[ORM\OrderBy(['rank' => 'ASC'])]
private ?Collection $attemptBlocks;
#[ORM\OneToOne(targetEntity: GoogleExportedData::class, cascade: ['persist', 'remove'], orphanRemoval: true)]
#[ORM\JoinColumn(nullable: true, onDelete: 'SET NULL')]
private ?GoogleExportedData $googleExportedData = null;
public function __construct()
{
$this->accessToken = bin2hex(random_bytes(32));
$this->attemptBlocks = new ArrayCollection();
}
public function getId(): ?int
{
return $this->id;
}
public function getAccessToken(): ?string
{
return $this->accessToken;
}
public function setAccessToken(?string $accessToken): static
{
$this->accessToken = $accessToken;
return $this;
}
public function getStartedAt(): ?DateTime
{
return $this->startedAt;
}
public function setStartedAt(?DateTime $startedAt): static
{
$this->startedAt = $startedAt;
return $this;
}
public function getEndedAt(): ?DateTime
{
return $this->endedAt;
}
public function setEndedAt(?DateTime $endedAt): static
{
$this->endedAt = $endedAt;
return $this;
}
public function getTime(): ?int
{
return $this->time;
}
public function setTime(?int $time): static
{
$this->time = $time;
return $this;
}
public function getStatus(): ?string
{
return $this->status;
}
public function setStatus(?string $status): static
{
$this->status = $status;
return $this;
}
public function getResult(): ?string
{
return $this->result;
}
public function setResult(?string $result): static
{
$this->result = $result;
return $this;
}
public function isEmailConfirmed(): bool
{
return $this->emailConfirmed;
}
public function setEmailConfirmed(bool $emailConfirmed): static
{
$this->emailConfirmed = $emailConfirmed;
return $this;
}
public function getIsInterestedInWorkStudy(): ?bool
{
return $this->isInterestedInWorkStudy;
}
public function setIsInterestedInWorkStudy(?bool $isInterestedInWorkStudy): static
{
$this->isInterestedInWorkStudy = $isInterestedInWorkStudy;
return $this;
}
public function getIsInterestedByFindWorkStudyTrainee(): ?bool
{
return $this->isInterestedByFindWorkStudyTrainee;
}
public function setIsInterestedByFindWorkStudyTrainee(?bool $isInterestedByFindWorkStudyTrainee): static
{
$this->isInterestedByFindWorkStudyTrainee = $isInterestedByFindWorkStudyTrainee;
return $this;
}
public function getProspect(): ?Contact
{
return $this->prospect;
}
public function setProspect(?Contact $prospect): static
{
$this->prospect = $prospect;
return $this;
}
public function getChannelUserData(): ?ChannelUserData
{
return $this->channelUserData;
}
public function setChannelUserData(?ChannelUserData $channelUserData): static
{
$this->channelUserData = $channelUserData;
return $this;
}
public function getPositioningTest(): ?PositioningTest
{
return $this->positioningTest;
}
public function setPositioningTest(?PositioningTest $positioningTest): static
{
$this->positioningTest = $positioningTest;
return $this;
}
/**
* @return Collection<int, AttemptBlock>|null
*/
public function getAttemptBlocks(): ?Collection
{
return $this->attemptBlocks;
}
public function addAttemptBlock(AttemptBlock $attemptBlock): self
{
if (!$this->attemptBlocks->contains($attemptBlock)) {
$attemptBlock->setAttempt($this);
$this->attemptBlocks[] = $attemptBlock;
}
return $this;
}
public function removeAttemptBlock(AttemptBlock $attemptBlock): self
{
if ($this->attemptBlocks->contains($attemptBlock)) {
$this->attemptBlocks->removeElement($attemptBlock);
}
return $this;
}
public function getGoogleExportedData(): ?GoogleExportedData
{
return $this->googleExportedData;
}
public function setGoogleExportedData(?GoogleExportedData $googleExportedData): static
{
$this->googleExportedData = $googleExportedData;
return $this;
}
}