<?php
namespace CoreBundle\Entity;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
use JsonSerializable;
/**
* @ORM\Table("problem_dnd")
* @ORM\Entity(repositoryClass="CoreBundle\Entity\ProblemDndRepository")
*/
class ProblemDnd implements JsonSerializable
{
const BLOCK_TYPE = 'block';
/**
* @ORM\Column(name="id", type="integer")
* @ORM\Id
* @ORM\GeneratedValue(strategy="AUTO")
*/
private int $id;
/**
* @ORM\OneToOne(targetEntity="Mathproblem")
*/
private Mathproblem $problem;
/**
* @ORM\OneToMany(targetEntity="ProblemDndBin", mappedBy="problemDnd")
*/
private Collection $bins;
/**
* @ORM\Column(name="bins_shuffled", type="boolean")
*/
private bool $binsShuffled;
/**
* @ORM\Column(name="single_bin", type="boolean")
*/
private bool $singleBin;
/**
* @ORM\Column(name="type", type="string", nullable=true)
*/
private $type = null;
/**
* @ORM\Column(type="boolean")
*/
private bool $horizontal;
/**
* @ORM\Column(name="multi", type="boolean")
*/
private bool $multi;
public function __construct()
{
$this->bins = new ArrayCollection();
}
public function getId(): int
{
return $this->id;
}
public function getProblem(): Mathproblem
{
return $this->problem;
}
/**
* @return Collection|ArrayCollection|ProblemDndBin[]
*/
public function getBins(): Collection
{
return $this->bins;
}
public function isMulti(): bool
{
return $this->multi;
}
public function isBinsShuffled(): bool
{
return $this->binsShuffled;
}
public function setBinsShuffled(bool $BinsShuffled)
{
$this->binsShuffled = $BinsShuffled;
}
public function isSingleBin(): bool
{
return $this->singleBin;
}
public function setSingleBin(bool $singleBin)
{
$this->singleBin = $singleBin;
}
public function isHorizontal(): bool
{
return $this->horizontal;
}
public function setHorizontal(bool $horizontal)
{
$this->horizontal = $horizontal;
}
/**
* @param string $type
* @return $this
*/
function setType(string $type): self{
$this->type = $type;
return $this;
}
/**
* @return string|null
*/
function getType(): string|null{
return $this->type;
}
public function setProblem(Mathproblem $problem): void
{
$this->problem = $problem;
}
public function setMulti(bool $multi): void
{
$this->multi = $multi;
}
public function getBinByIndex(int $index)
{
foreach ($this->getBins() as $bin) {
if ($bin->getIndex() === $index)
return $bin;
}
return null;
}
public function jsonSerialize(): mixed
{
return [
"id" => $this->id,
"binsShuffled" => $this->binsShuffled,
"singleBin" => $this->singleBin,
"horizontal" => $this->horizontal,
"multi" => $this->multi,
"type" => $this->type
];
}
}