<?php
namespace App\Entity;
use Doctrine\ORM\Mapping as ORM;
use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
use Symfony\Component\Validator\Constraints as Assert;
/**
* @ORM\Entity()
*
* @ORM\Table(name="parameter")
*/
class Parameter
{
/**
* @ORM\Column(type="integer")
*
* @ORM\Id
*
* @ORM\GeneratedValue(strategy="AUTO")
*/
private $id;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
private $value;
/**
* @ORM\Column(name="array_value", type="array", nullable=true)
*/
private $arrayValue;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
private $type;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
private $category;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
private $tooltip;
public function __construct(/**
* @ORM\Column
*
* @Assert\NotBlank
*/
private $name, $value = null)
{
$this->setValue($value);
}
public function getId()
{
return $this->id;
}
public function getName()
{
return $this->name;
}
public function setName($name): void
{
$this->name = $name;
}
public function getValue()
{
if ($this->isArray()) {
return $this->arrayValue;
}
return $this->value;
}
public function setValue($value)
{
$arrayValue = null;
$scalarValue = null;
if (true === is_array($value)) {
$arrayValue = array_values($value);
} elseif (false === is_null($value)) {
$scalarValue = $value;
}
$this->value = $scalarValue;
$this->arrayValue = $arrayValue;
return $this;
}
public function getType()
{
return $this->type;
}
public function setType($type): void
{
$this->type = $type;
}
public function getCategory()
{
return $this->category;
}
public function setCategory($category): void
{
$this->category = $category;
}
public function getTooltip(): ?string
{
return $this->tooltip;
}
public function setTooltip($tooltip): void
{
$this->tooltip = $tooltip;
}
private function isArray()
{
return null === $this->value;
}
}