Code Duplication    Length = 29-29 lines in 2 locations

src/DoctrineDbalServiceProvider.php 1 location

@@ 54-82 (lines=29) @@
51
     *
52
     * @return \Closure
53
     */
54
    private function getDbsOptionsInitializerDefinition(Container $container): \Closure
55
    {
56
        return $container->protect(function () use ($container) {
57
            static $initialized = false;
58
59
            if ($initialized) {
60
                return;
61
            }
62
63
            $initialized = true;
64
65
            if (!isset($container['dbs.options'])) {
66
                $container['dbs.options'] = [
67
                    'default' => isset($container['db.options']) ? $container['db.options'] : [],
68
                ];
69
            }
70
71
            $tmp = $container['dbs.options'];
72
            foreach ($tmp as $name => &$options) {
73
                $options = array_replace($container['db.default_options'], $options);
74
75
                if (!isset($container['dbs.default'])) {
76
                    $container['dbs.default'] = $name;
77
                }
78
            }
79
80
            $container['dbs.options'] = $tmp;
81
        });
82
    }
83
84
    /**
85
     * @param Container $container

src/DoctrineMongoDbServiceProvider.php 1 location

@@ 50-78 (lines=29) @@
47
     *
48
     * @return \Closure
49
     */
50
    private function getMongoDbsOptionsInitializerDefinition(Container $container): \Closure
51
    {
52
        return $container->protect(function () use ($container) {
53
            static $initialized = false;
54
55
            if ($initialized) {
56
                return;
57
            }
58
59
            $initialized = true;
60
61
            if (!isset($container['mongodbs.options'])) {
62
                $container['mongodbs.options'] = [
63
                    'default' => isset($container['mongodb.options']) ? $container['mongodb.options'] : [],
64
                ];
65
            }
66
67
            $tmp = $container['mongodbs.options'];
68
            foreach ($tmp as $name => &$options) {
69
                $options = array_replace_recursive($container['mongodb.default_options'], $options);
70
71
                if (!isset($container['mongodbs.default'])) {
72
                    $container['mongodbs.default'] = $name;
73
                }
74
            }
75
76
            $container['mongodbs.options'] = $tmp;
77
        });
78
    }
79
80
    /**
81
     * @param Container $container