protected function arrayMerge(array $target, array $source)
    {
        foreach ($source as $key => $value) {
            if ($value instanceof MergingInterface) {
                $value = $value->toArray();
            }
            if (isset($target[$key]) || array_key_exists($key, $target)) {
                if (is_int($key)) {
                    $target[] = $value;
                } elseif (is_array($value) && is_array($target[$key])) {
                    $target[$key] = $this->arrayMerge($target[$key], $value);
                } else {
                    $target[$key] = $value;
                }
            } else {
                $target[$key] = $value;
            }
        }

        return $target;
    }