This commit is contained in:
2026-02-17 14:56:23 +01:00
commit 68f7a95fdf
695 changed files with 154611 additions and 0 deletions

View File

@@ -0,0 +1,34 @@
<?php
namespace DynCom\mysyde\common\traits;
/**
* Created by PhpStorm.
* User: Bauer
* Date: 08.10.2015
* Time: 10:42
*/
trait reflectionIDSetter
{
/**
* @param $object
* @param $id
*/
public function setID($object, $id)
{
$id = (int)$id;
if(!is_object($object)) {
throw new \InvalidArgumentException("Parameter 'object' must be an object.");
}
if(!($id > 0)) {
throw new \InvalidArgumentException("Parameter 'id' must be a positive integer.");
}
$reflClass = new \ReflectionClass($object);
if(!$reflClass->hasProperty('id')) {
throw new \InvalidArgumentException("Object has no property 'id'.");
}
$idProp = $reflClass->getProperty('id');
$idProp->setAccessible(true);
$idProp->setValue($object,$id);
}
}