Files
fdn2/app/private/lib/constrained/ConstrainedFactory.php
T
2022-08-29 23:20:16 +02:00

37 lines
654 B
PHP

<?php
/*
Author: Riccardo Di Dato
Creation Date: 08/gen/2016
*/
class ConstrainedFactory {
public static function build($obj){
$rval = $obj;
if ($obj instanceof ConstrainedInterface){
$rval = clone $obj;
}
else if (is_object($obj)){
$rval = new ConstrainedObject($obj);
}
else if (is_array($obj)){
$rval = new ConstrainedArrayObject($obj);
}
return $rval;
}
public static function debuild($obj){
$rval = $obj;
if ($obj instanceof ConstrainedInterface){
$rval = new stdClass();
$tmp = $obj->getBase();
foreach ($tmp as $key=>$val){
$rval->$key = self::debuild($val);
}
}
return $rval;
}
}
?>