A fast and light-weight component library
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

72 lines
1.2 KiB

7 years ago
<?php
7 years ago
namespace Twister\ORM;
7 years ago
7 years ago
/**
* Similar Examples
* ----------------
* @link https://github.com/analogueorm/analogue/blob/5.5/src/Entity.php
*
* Interfaces
* ----------
* @link http://php.net/JsonSerializable
*/
abstract class Entity implements \JsonSerializable
7 years ago
{
7 years ago
protected $properties;
7 years ago
protected $map; // AKA config; can include relations, factory methods for relations etc.
7 years ago
7 years ago
function __construct(array $properties = null)
7 years ago
{
$this->properties =& $properties;
}
/**
* Get entity field/property
*
* @param string $name
* @return mixed
*/
7 years ago
function __get($name)
7 years ago
{
7 years ago
if ( ! isset($this->properties[$name]))
{
if (isset($this->map[$name]))
{
}
}
7 years ago
return $this->properties[$name];
7 years ago
}
7 years ago
// abstract private relation($name);
// abstract private __get__();
7 years ago
/**
* Set entity field/property
*
* @param string $name
* @param mixed $value
* @return void
*/
7 years ago
function __set($name, $value)
7 years ago
{
$this->properties[$name] = $value;
}
7 years ago
function __isset($name)
7 years ago
{
return isset($this->properties[$name]);
}
7 years ago
function __unset($name)
7 years ago
{
unset($this->properties[$name]);
}
7 years ago
function jsonSerialize()
{
return $this->properties;
}
7 years ago
}