Create a Key Path Element from array

@param array $arr_kpe
@return \stdClass
556071
protected function createKeyPathElement(array $arr_kpe)
    {
        $obj_element = (object)['kind' => $arr_kpe['kind']];
        if(isset($arr_kpe['id'])) {
            $obj_element->id = $arr_kpe['id'];
        } elseif (isset($arr_kpe['name'])) {
            $obj_element->name = $arr_kpe['name'];
        }
        return $obj_element;
    }
738694
public static function array_delete(&$arr, $path) {
		if(!$path)
			return;
		if(!is_array($path))
			$path = [$path];
		$lastkey = array_pop($path);
		foreach($path as $parent)
			$arr =& $arr[$parent];
		unset($arr[$lastkey]);
	}
298966
public function denormalize(array $arr, $class)
    {
        $properties = $this->getClassProperties($class);
        $obj = new $class;
        foreach ($properties as $name => $prop) {
            if (isset($prop['serializeName'])) {
                $name = $prop['serializeName'];
            }
            if (!isset($arr[$name])) {
                continue;
            }
            $value = $arr[$name];
            if (isset($prop['type'])) {
                if ($prop['type'] === 'array') {
                    $value = array_map(function ($elem) use ($prop) {
                        return $this->denormalize($elem, $prop['element']);
                    }, $value);
                } else {
                    $value = $this->denormalize($value, $prop['type']);
                }
            }
            if (isset($prop['setter'])) {
                $setter = $prop['setter'];
                $obj->$setter($value);
            } else {
                $key = $prop['name'];
                $obj->$key = $value;
            }
        }
        return $obj;
    }
326976
protected function prepareTree(array $arr) {
        $tree = [];
        foreach ($arr as $a) {
            $name = $a->getName();
            $cur = &$tree;
            foreach (explode("-", $name) as $e) {
                if (empty($cur[$e])) $cur[$e] = [];
                $cur = &$cur[$e];
            }
        }
        return $tree;
    }
116778
public static function arrMergeAll(array &$arr, $arr2)
    {
        if (is_array($arr2)) {
            foreach ($arr2 as $key => $val) {
                $arr[$key] = $val;
            }
        } else {
            $arr[] = $arr2;
        }

        return $arr;
    }
629980
private function pathSlashToStruct($assocarray) {
        $new_assocarray = [];

        $this->switchType();

        if (is_array($assocarray)) {
            foreach ($assocarray as $key => $value) {
                if (strpos($key, '/') !== false) {
                    $aux = explode("/", $key);
                    $newkey = $aux[0];
                    array_shift($aux);

                    if (isset($new_assocarray[$newkey])) {
                        $new_assocarray[$newkey] = $this->createDynamicallyObjects($new_assocarray[$newkey], $aux);
                        $new_assocarray[$newkey] = $this->setDynamicallyValue($new_assocarray[$newkey], $aux, $value);
                    } else {
                        $new_assocarray[$newkey] = $this->createDynamicallyObjects(array(), $aux);
                        $new_assocarray[$newkey] = $this->setDynamicallyValue($new_assocarray[$newkey], $aux, $value);
                    } 
                } else {
                    $new_assocarray[$key] = $value;
                }
            }
        }

        $this->switchType();

        return $new_assocarray;
    }
1312913
public function generateKey(array $options = [])
	{
		$passphrase = $options['passphrase'] ?? false;

		if ($passphrase === false)
		{
			throw new \RuntimeException('Missing passphrase file');
		}

		return new Key('openssl', $passphrase, 'unused');
	}
1124080
public static function arrayKeyUpper($arr)
    {
        return array_map(function($item){
            if(is_array($item)) {
                $item = self::arrayKeyUpper($item);
            }
            return $item;
        },array_change_key_case($arr,CASE_UPPER));
    }
841553
public function assignArrayByPath(&$arr, $path)
    {
        $keys = explode('.', $path);

        while ($key = array_shift($keys)) {
            $arr = &$arr[$key];
        }

        return $arr;
    }
1067048
public function fromArray($arr)
    {
        $class = $this->getModel();
        foreach ($arr as $element) {
            /** @var $obj BaseObject */
            $obj = new $class();
            $obj->fromArray($element);
            $this->append($obj);
        }
    }
24881
public static function createFromArray($key, array $data = [], ApiDefinition $apiDefinition = null)
    {
        $securityScheme = new static($key === 'null' ? null : $key);

        if (isset($data['description'])) {
            $securityScheme->setDescription($data['description']);
        }

        if (isset($data['type'])) {
            $securityScheme->setType($data['type']);
        }

        if (isset($data['describedBy'])) {
            $securityScheme->setDescribedBy(
                SecuritySchemeDescribedBy::createFromArray('describedBy', $data['describedBy'])
            );
        }

        if (isset($data['settings'])) {
            $securityScheme->setSettings($data['settings']);
        }

        return $securityScheme;
    }
1333357
private function formatArrayField($arr, $pk = null)
    {
        $ret = [];
        foreach ($arr as $k => $v) {
            if ($pk !== null) {
                $k = $pk . $k;
            }
            if (is_array($v)) {
                $ret = array_merge($ret, $this->formatArrayField($v, $k . ']['));
            } else {
                $ret[$k] = $v;
            }
        }
        return $ret;
    }
1155309
static public function replaceArrayKeyWithArray($arr = [],$field = '')
    {
        $newArr = [];
        if($arr){
            foreach ($arr as $value) {
                $newArr[$value[$field]][] = $value;
            }
        }
        return $newArr;
    }
666281
protected function create(array $data)
    {
        $admin = new Admin();

        $fields           = $this->tableFields();
        $data['password'] = bcrypt($data['password']);
        foreach ($fields as $field) {
            if (isset($data[$field])) {
                $admin->$field = $data[$field];
            }
        }

        $admin->save();
        $admin->roles()->sync(request('role_id'));
        $this->sendConfirmationNotification($admin, request('password'));

        return $admin;
    }
1160041
public static function from_array($arr)
    {
        $obj = new rcube_message_header;
        foreach ($arr as $k => $v)
            $obj->set($k, $v);

        return $obj;
    }
160488
public function fromArray($arr)
    {
        if (!empty($arr)) {
            // Iterate over each element in array
            foreach ($arr as $k => $v) {
                // If the value is an array, it means, it is an object after conversion
                if (is_array($v)) {
                    // Determine the class of the object
                    if (($clazz = ReflectionUtil::getPropertyClass(get_class($this), $k)) != null) {
                        // If the value is an associative array, it means, its an object. Just make recursive call to it.
                        if (empty($v)) {
                            if (ReflectionUtil::isPropertyClassArray(get_class($this), $k)) {
                                // It means, it is an array of objects.
                                $this->assignValue($k, array());
                                continue;
                            }
                            $o = new $clazz();
                            //$arr = array();
                            $this->assignValue($k, $o);
                        } elseif (ArrayUtil::isAssocArray($v)) {
                            /** @var BlockCypherModel $o */
                            $o = new $clazz();
                            $o->fromArray($v);
                            $this->assignValue($k, $o);
                        } else {
                            // Else, value is an array of object/data
                            $arr = array();
                            // Iterate through each element in that array.
                            foreach ($v as $nk => $nv) {
                                if (is_array($nv)) {
                                    //BlockCypherLoggingManager::getInstance()->debug("new instance of class: $clazz");
                                    if (!class_exists($clazz)) {
                                        BlockCypherLoggingManager::getInstance()->error("Class not found: $clazz");
                                    } else {
                                        try {
                                            $o = new $clazz();
                                            $o->fromArray($nv);
                                            $arr[$nk] = $o;
                                        } catch (\Exception $e) {
                                            BlockCypherLoggingManager::getInstance()->error($e->getMessage());
                                        }
                                    }
                                } else {
                                    $arr[$nk] = $nv;
                                }
                            }
                            $this->assignValue($k, $arr);
                        }
                    } else {
                        $this->assignValue($k, $v);
                    }
                } else {
                    $this->assignValue($k, $v);
                }
            }
        }
        return $this;
    }
922528
protected function key(array $notice): string
    {
        $hashable_notice = $this->normalize($notice);
        unset($hashable_notice['_insertion_time']);
        unset($hashable_notice['_recurrences']);
        unset($hashable_notice['_last_recur_dismiss_time']);

        if ($hashable_notice['id']) {
            return $hashable_notice['id']; // Use as key.
        }
        return $this->c::sha256KeyedHash(serialize($hashable_notice));
    }