File: D:/HostingSpaces/SBogers95/rentman.io/app/Komma/Kms/Core/Attributes/Models/DataTableColumn.php
<?php
namespace App\Komma\Kms\Core\Attributes\Models;
/**
* Class DataTableColumn
*/
class DataTableColumn
{
const INPUT_TEXT = 1;
const TEXTAREA = 2;
const ON_OFF = 3;
/**
* Name for the heading of the table
*
* @var string;
*/
private $name;
/**
* The type of field we want to display
*
* @var int
*/
private $columnType;
/**
* Determine of the field is locked or not
*
* @var bool
*/
private $locked;
/**
* The flex ration of the field
*
* @var int
*/
private $flexRatio;
/**
* DataTableColumn constructor.
* @param int $columnType
* @param string $name
* @param bool $locked
* @param int $flexRatio
*/
public function __construct(int $columnType, string $name = '', bool $locked = false, int $flexRatio = 1)
{
$this->columnType = $columnType;
$this->name = $name;
$this->locked = $locked;
$this->setFlexRatio($flexRatio);
}
/**
* @return string
*/
public function getName(): string
{
return $this->name;
}
/**
* @param string $name
* @return DataTableColumn
*/
public function setName(string $name): self
{
$this->name = $name;
return $this;
}
/**
* @return int
*/
public function getColumnType(): int
{
return $this->columnType;
}
/**
* @param int $columnType
* @return DataTableColumn
*/
public function setColumnType(int $columnType): self
{
$this->columnType = $columnType;
return $this;
}
/**
* @return bool
*/
public function isLocked(): bool
{
return $this->locked;
}
/**
* Because we have an additional line / check we have created function
* instead of adding it directly on the construct method.
*
* @param int $flexRatio
*/
private function setFlexRatio(int $flexRatio): void
{
if ($flexRatio > 3) {
throw new \OutOfRangeException(self::class.': Maximum allowed flex ration is 3');
}
$this->flexRatio = $flexRatio;
}
/**
* @return int
*/
public function getFlexRatio(): int
{
return $this->flexRatio;
}
}