src/Primitive/Container/Container.php
public function pushToKey($key, $value)
    {
        if ( ! $this->has($key))
        {
            $this->set($key, []);
        }

        $keyValue = $this->get($key);

        if ($keyValue instanceof static)
        {
            $keyValue->push($value);
        }
        elseif (is_array($keyValue))
        {
            $keyValue[] = $value;
        }
        else
        {
            $this->set($key, [])->pushToKey($key, $keyValue);

            return $this;
        }

        $this->set($key, $keyValue);

        return $this;
    }
public function pushToKey($key, $value)
    {
        if ( ! $this->has($key))
        {
            $this->set($key, []);
        }

        $keyValue = $this->get($key);

        if ($keyValue instanceof static)
        {
            $keyValue->push($value);
        }
        elseif (is_array($keyValue))
        {
            $keyValue[] = $value;
        }
        else
        {
            $this->set($key, [])->pushToKey($key, $keyValue);

            return $this;
        }

        $this->set($key, $keyValue);

        return $this;
    }
Push value to specified key

@param mixed $key
@param mixed $value
@return $this