mirror of
https://github.com/Karaka-Management/phpOMS.git
synced 2026-02-06 12:38:40 +00:00
Optimize indention
This commit is contained in:
parent
e92df825fe
commit
fdcc81a3d1
|
|
@ -1742,33 +1742,35 @@ class DataMapperAbstract implements DataMapperInterface
|
||||||
$reflectionClass = new \ReflectionClass($obj);
|
$reflectionClass = new \ReflectionClass($obj);
|
||||||
|
|
||||||
foreach ($result as $column => $value) {
|
foreach ($result as $column => $value) {
|
||||||
if (isset(static::$columns[$column]['internal']) /* && $reflectionClass->hasProperty(static::$columns[$column]['internal']) */) {
|
if (!isset(static::$columns[$column]['internal']) /* && $reflectionClass->hasProperty(static::$columns[$column]['internal']) */) {
|
||||||
$reflectionProperty = $reflectionClass->getProperty(static::$columns[$column]['internal']);
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
if (!($accessible = $reflectionProperty->isPublic())) {
|
$reflectionProperty = $reflectionClass->getProperty(static::$columns[$column]['internal']);
|
||||||
$reflectionProperty->setAccessible(true);
|
|
||||||
|
if (!($accessible = $reflectionProperty->isPublic())) {
|
||||||
|
$reflectionProperty->setAccessible(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (in_array(static::$columns[$column]['type'], ['string', 'int', 'float', 'bool'])) {
|
||||||
|
if ($value !== null || $reflectionProperty->getValue($obj) !== null) {
|
||||||
|
settype($value, static::$columns[$column]['type']);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (in_array(static::$columns[$column]['type'], ['string', 'int', 'float', 'bool'])) {
|
$reflectionProperty->setValue($obj, $value);
|
||||||
if ($value !== null || $reflectionProperty->getValue($obj) !== null) {
|
} elseif (static::$columns[$column]['type'] === 'DateTime') {
|
||||||
settype($value, static::$columns[$column]['type']);
|
$reflectionProperty->setValue($obj, new \DateTime($value ?? ''));
|
||||||
}
|
} elseif (static::$columns[$column]['type'] === 'Json') {
|
||||||
|
$reflectionProperty->setValue($obj, json_decode($value, true));
|
||||||
|
} elseif (static::$columns[$column]['type'] === 'Serializable') {
|
||||||
|
$member = $reflectionProperty->getValue($obj);
|
||||||
|
$member->unserialize($value);
|
||||||
|
} else {
|
||||||
|
throw new \UnexpectedValueException('Value "' . static::$columns[$column]['type'] . '" is not supported.');
|
||||||
|
}
|
||||||
|
|
||||||
$reflectionProperty->setValue($obj, $value);
|
if (!$accessible) {
|
||||||
} elseif (static::$columns[$column]['type'] === 'DateTime') {
|
$reflectionProperty->setAccessible(false);
|
||||||
$reflectionProperty->setValue($obj, new \DateTime($value ?? ''));
|
|
||||||
} elseif (static::$columns[$column]['type'] === 'Json') {
|
|
||||||
$reflectionProperty->setValue($obj, json_decode($value, true));
|
|
||||||
} elseif (static::$columns[$column]['type'] === 'Serializable') {
|
|
||||||
$member = $reflectionProperty->getValue($obj);
|
|
||||||
$member->unserialize($value);
|
|
||||||
} else {
|
|
||||||
throw new \UnexpectedValueException('Value "' . static::$columns[$column]['type'] . '" is not supported.');
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!$accessible) {
|
|
||||||
$reflectionProperty->setAccessible(false);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user