private static function &dataByPath(array &$data, string $key, bool $create = false, $defaultValue = null)
    {
        if ($key === '') {
            return $data;
        }
        $pathSegments = explode('.', $key);
        foreach ($pathSegments as $pathSegment) {
            if (!is_array($data)) {
                $data = [];
            }
            if (!array_key_exists($pathSegment, $data) && !$create) {
                return $defaultValue;
            }
            $data = &$data[$pathSegment];
        }
        return $data;
    }
private static function &dataByPath(array &$data, string $key, bool $create = false, $defaultValue = null)
    {
        if ($key === '') {
            return $data;
        }
        $pathSegments = explode('.', $key);
        foreach ($pathSegments as $pathSegment) {
            if (!is_array($data)) {
                $data = [];
            }
            if (!array_key_exists($pathSegment, $data) && !$create) {
                return $defaultValue;
            }
            $data = &$data[$pathSegment];
        }
        return $data;
    }
private static function & dataByPath ( array & $ data , string $ key , bool $ create = false , $ defaultValue = null ) { if ( $ key === '' ) { return $ data ; } $ pathSegments = explode ( '.' , $ key ) ; foreach ( $ pathSegments as $ pathSegment ) { if ( ! is_array ( $ data ) ) { $ data = [ ] ; } if ( ! array_key_exists ( $ pathSegment , $ data ) && ! $ create ) { return $ defaultValue ; } $ data = & $ data [ $ pathSegment ] ; } return $ data ; }
Get data by path.

@param mixed[] $data
@param string $key Uses dot notation.
@param bool $create Default false.
@param mixed $defaultValue Default null.
@return mixed
Get data by path .