File: D:/HostingSpaces/SBogers60/agrimac.nl/workbench/komma/kms/src/Komma/Kms/Core/Entities/KmsEntity.php
<?php
/**
* Short description for the file.
*
* @author Komma <info@komma.pro>
* @copyright (c) 2012-2015, Komma Mediadesign
*/
namespace Komma\Kms\Core\Entities;
abstract class KmsEntity
{
public $id;
public $name;
public $thumbnail;
function __construct(array $data = [], $id = null)
{
$this->fill($data, $id);
}
abstract public function getName();
public function fill(array $data = [], $id = null)
{
$this->id = $id;
foreach($data as $key => $value)
{
if(property_exists($this, $key)){
$this->{$key} = $value;
}
}
}
public function setId($id)
{
$this->id = $id;
}
public function getId()
{
return $this->id;
}
public function getValue($key)
{
if(property_exists($this, $key))
{
return $this->{$key};
}
return null;
}
public function setValue($key, $value)
{
if(property_exists($this, $key))
{
return $this->{$key} = $value;
}
return null;
}
public function getThumbnail()
{
if(isset($this->album_thumbnail)) $this->thumbnail = $this->album_thumbnail;
if(isset($this->thumbnail) && $this->thumbnail != "")
{
return '<img src="'.$this->thumbnail.'"/>';
}
return substr($this->getName(), 0, 1);
}
}