Compare commits
3 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
73b7cb3a5f | ||
|
|
4f7993750c | ||
|
|
bdff890b41 |
@@ -48,7 +48,7 @@ abstract class AbstractRepository implements RepositoryInterface {
|
|||||||
if(!isset(static::$classes[$class])) static::$classes[$class] = new ReflectionClass($class);
|
if(!isset(static::$classes[$class])) static::$classes[$class] = new ReflectionClass($class);
|
||||||
/** @var ReflectionProperty $property */
|
/** @var ReflectionProperty $property */
|
||||||
foreach(static::$classes[$class]->getProperties() as $property){
|
foreach(static::$classes[$class]->getProperties() as $property){
|
||||||
if(!$property->isInitialized($object)) continue;
|
if(!$property->isInitialized($object) || is_array($property->getValue($object))) continue;
|
||||||
if(static::$classes[$class]->hasMethod('get'.ucfirst($property->getName()))){
|
if(static::$classes[$class]->hasMethod('get'.ucfirst($property->getName()))){
|
||||||
$fieldValue[$property->getName()] = $object->{'get'.ucfirst($property->getName())}($property->getValue($object));
|
$fieldValue[$property->getName()] = $object->{'get'.ucfirst($property->getName())}($property->getValue($object));
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,10 +5,27 @@ namespace Rmphp\Storage\Entity;
|
|||||||
abstract class AbstractEntity implements EntityInterface {
|
abstract class AbstractEntity implements EntityInterface {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return int|null
|
* @return mixed
|
||||||
*/
|
*/
|
||||||
public function getId(): mixed {
|
public function getId(): mixed {
|
||||||
return (isset($this->id)) ? (($this->id instanceof ValueObjectInterface) ? $this->id->get() : $this->id) : null;
|
return (isset($this->id)) ? (($this->id instanceof ValueObjectInterface) ? $this->id->get() : $this->id) : null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param string $name
|
||||||
|
* @param $value
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function __set(string $name, $value): void {
|
||||||
|
$this->$name = $value;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param string $name
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function __get(string $name) {
|
||||||
|
return $this->$name ?? "";
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ namespace Rmphp\Storage\Entity;
|
|||||||
interface EntityInterface {
|
interface EntityInterface {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return int|null
|
* @return mixed
|
||||||
*/
|
*/
|
||||||
public function getId(): mixed;
|
public function getId(): mixed;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user