for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
declare(strict_types = 1);
namespace Zortje\MVC\Model\Table\Entity;
/**
* Class EntityProperty
*
* @package Zortje\MVC\Model\Table\Entity
*/
class EntityProperty
{
* @var string Entity property type
protected $type;
* @param string $type
public function __construct(string $type)
$this->type = $type;
}
* Format value according to entity property type
* @param mixed $value Value
* @return mixed Value
public function formatValueForEntity($value)
switch ($this->type) {
case 'string':
$value = "$value";
break;
case 'integer':
$value = (int)$value;
case 'float':
$value = (float)$value;
case 'date':
case 'datetime':
$value = new \DateTime($value);
return $value;
* Format value for insertion into the database
public function formatValueForDatabase($value)
* @var \DateTime $value
$value = $value->format('Y-m-d');
$value = $value->format('Y-m-d H:i:s');