Add a layer of depth to the key hierarchy

@param string $layer

@return string The new base key
484954
public function pushKey($layer)
    {
        $this->base .= $this->delimiter . str_replace($this->delimiter, $this->placeholder, $layer);
        return $this->getBase();
    }
221434
public static function flatten($array, $depth = INF)
    {
        if ($array instanceof ArrayAble) {
            $array = $array->toArray();
        }
        return array_reduce($array, function ($result, $item) use ($depth) {
            if (!is_array($item)) {
                return array_merge($result, [$item]);
            } else if($depth === 1) {
                return array_merge($result, array_values($item));
            } else {
                return array_merge($result, static::flatten($item, $depth - 1));
            }
        }, []);
    }
912185
public function commit()
    {
        if (!$this->nested || $this->depth <= 1) {
            parent::commit();
        } else {
            $this->depth--;
        }

        return $this;
    }
712295
private Collection<Displayable> getLayer(Integer layer)
    {
        final Collection<Displayable> displayables;
        if (!layers.containsKey(layer))
        {
            displayables = new HashSet<>();
            layers.put(layer, displayables);
        }
        else
        {
            displayables = layers.get(layer);
        }
        return displayables;
    }
961072
protected boolean addLayer(Layer layer) {
		int index = getLayerIndex(layer);
		if (index < 0) {
			view.add(new LayerControlPanel(mapPresenter, layer, disableToggleOutOfRange));

			return true;
		}
		return false;
	}
1009395
public LienzoPanel add(final Layer layer, final Layer... layers)
    {
        add(layer);

        for (final Layer node : layers)
        {
            add(node);
        }
        return this;
    }
268861
public function popKey()
    {
        if (strlen($this->base)) {
            $layers = explode($this->delimiter, $this->base);
            $last = count($layers) - 1;
            $layer = $layers[$last];
            if ($last > 0) {
                unset ($layers[$last]);
                $this->base = implode($this->delimiter, $layers);
            } else {
                $this->base = '';
            }
            return $layer;
        }

        return null;
    }
224888
public function asArray($depth = INF)
    {
        if (!$depth || $depth <= 0) {
            return $this->data;
        }

        $results = [];

        foreach (parent::asArray() as $key => $data) {
            $results[$key] =
                $data instanceof self ?
                    $data->asArray(\is_bool($depth) ? INF : --$depth) :
                    $data;
        }

        return $results;
    }
26379
protected function _addKey($key)
    {
        if ($key == '__stored_keys__') {
            return $this;
        }

        $keys = $this->get('__stored_keys__', []);
        if (!in_array($key, $keys)) {
            array_push($keys, $key);
        }
        $this->set('__stored_keys__', $keys, 24*60*60);
        return $this;
    }
1150809
public function encodeControlLayers(Layers $layers, Encoder $encoder)
    {
        return sprintf(
            '%s = L.control.layers(%s, %s, %s);',
            $encoder->encodeReference($layers),
            $this->encodeLayersInformation($layers->getBaseLayers(), $encoder),
            $this->encodeLayersInformation($layers->getOverlays(), $encoder),
            $encoder->encodeValue($layers->getOptions())
        );
    }
959748
public static function arrayToJSON(array $entities, $depth=0) {
		foreach($entities as $k=>$entity)
			$entities[$k] = $entity->toArray($depth);
		return json_encode($entities);
	}
690928
public function encodeTileLayer(TileLayer $layer, Encoder $builder)
    {
        return sprintf(
            '%s = L.tileLayer(%s);',
            $builder->encodeReference($layer),
            $builder->encodeArguments(array($layer->getUrl(), $layer->getOptions()))
        );
    }
380662
protected function arrayDepth($element, $depth = 1) {
        if (is_array($element)) {
            $maxDepth = $depth;
            foreach($element as $el) {
                $d = $this->arrayDepth($el, $depth + 1);
                if ($d > $maxDepth) {
                    $maxDepth = $d;
                }
            }
            return $maxDepth;
        } else {
            return $depth;
        }
    }
1228361
function(layer) {
            var layers = this.layers,
                len, n;

            if (layers) {
                len = layers.length;

                // don't add the layer if it already exists
                for (n = 0; n < len; n++) {
                    if (layers[n]._id === layer._id) {
                        return false;
                    }
                }
            }
            else {
                this.layers = [];
            }

            this.layers.push(layer);
            return true;
        }
886273
public function level($level)
    {
        if ($level === null) {
            return $this;
        }
        
        $this->prepend = '   ' . (str_repeat('  ', $level));
        
        return $this;
    }
844618
function array_map_deep($array, $callback) {
        $new = array();
        if(is_array($array)) foreach ($array as $key => $val) {
            if (is_array($val)) {
                $new[$key] = $this->array_map_deep($val, $callback);
            } else {
                $item = call_user_func($callback, $key, $val);
                $new[$item['key']] = $item['item'];
            }
        }
        else $new = call_user_func($callback, $array);
        return $new;
    }
14939
protected function upLevels($pathname, $depth)
    {
        if ($depth < 0) {
            return null;
        }
        while ($depth--) {
            $pathname = dirname($pathname);
        }
        return $pathname;
    }