Improve parsing of parameters when giving them back
Update some things to php 8
This commit is contained in:
@ -2,7 +2,10 @@
|
||||
|
||||
namespace Ardent\ParameterBundle\Entity;
|
||||
|
||||
use Doctrine\DBAL\Types\TextType;
|
||||
use Doctrine\ORM\Mapping as ORM;
|
||||
use Symfony\Component\Form\Extension\Core\Type\CheckboxType;
|
||||
use Symfony\Component\Form\Extension\Core\Type\NumberType;
|
||||
|
||||
/**
|
||||
* @ORM\Entity
|
||||
@ -15,57 +18,49 @@ class Parameter
|
||||
* @ORM\GeneratedValue(strategy="AUTO")
|
||||
* @ORM\Column(type="integer")
|
||||
*/
|
||||
private $id;
|
||||
private ?int $id;
|
||||
|
||||
/**
|
||||
* @ORM\Column(type="string")
|
||||
*/
|
||||
private $name;
|
||||
private ?string $name;
|
||||
|
||||
/**
|
||||
* @ORM\Column(type="string")
|
||||
*/
|
||||
private $value;
|
||||
private mixed $value;
|
||||
|
||||
/**
|
||||
* @return mixed
|
||||
*/
|
||||
public function getId()
|
||||
public function getId(): int
|
||||
{
|
||||
return $this->id;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return mixed
|
||||
*/
|
||||
public function getName()
|
||||
public function getName(): string
|
||||
{
|
||||
return $this->name;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param mixed $name
|
||||
* @return Parameter
|
||||
*/
|
||||
public function setName($name)
|
||||
public function setName(string $name): self
|
||||
{
|
||||
$this->name = $name;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return mixed
|
||||
*/
|
||||
public function getValue()
|
||||
public function getValue(): mixed
|
||||
{
|
||||
return $this->value;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param mixed $value
|
||||
* @return Parameter
|
||||
*/
|
||||
public function setValue($value)
|
||||
static function parseValue(mixed $value, string $type): mixed
|
||||
{
|
||||
return match ($type) {
|
||||
NumberType::class => intval($value),
|
||||
CheckboxType::class => boolval($value),
|
||||
default => $value,
|
||||
};
|
||||
}
|
||||
|
||||
public function setValue(mixed $value): self
|
||||
{
|
||||
$this->value = $value;
|
||||
return $this;
|
||||
|
Reference in New Issue
Block a user