3 Commits
5.0 ... 5.x

Author SHA1 Message Date
User
73b7cb3a5f 20250218#3 2025-02-18 01:24:05 +03:00
User
4f7993750c 20250218#2 2025-02-18 01:08:03 +03:00
User
bdff890b41 20250218#1 2025-02-18 00:14:52 +03:00
3 changed files with 20 additions and 3 deletions

View File

@@ -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));
} }

View File

@@ -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 ?? "";
}
} }

View File

@@ -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;