/** * Assign Properties * * Set/Update properties on the object using a key/value array * * @example * Object::assign(['value' => 'hi!'], new stdClass); * // object(stdClass)#1 (1) { * // ["value"]=> * // string(3) "hi!" * // } * * @type array props -> Object objOriginal -> Object objUpdated * * @param $props * @param $objOriginal * @return mixed */ protected static function __assign($props, $objOriginal) { $obj = clone $objOriginal; /** @noinspection PhpParamsInspection */ return Arrays::foldl(function ($obj, $setter) { return $setter($obj); }, $obj, Arrays::mapIndexed(Lambda::flip(self::setProp()), $props)); }
private function dictToList($dict) { if (!is_array($dict)) { return $dict; } return Arrays::mapIndexed(function ($v, $k) { return [$k => $this->dictToList($v)]; }, $dict); }