Code Duplication    Length = 27-27 lines in 2 locations

src/Builder/ContainerBuilder.php 2 locations

@@ 102-128 (lines=27) @@
99
     * @param Collection $connections
100
     * @return Collection
101
     */
102
    private function createExchanges(array $exchangeConfigList, Collection $connections): Collection
103
    {
104
        $exchanges = new Collection();
105
        foreach ($exchangeConfigList as $exchangeAliasName => $exchangeDetails) {
106
            // verify if the connection exists
107
            if (array_key_exists('connection', $exchangeDetails) &&
108
                false === $connections->has($exchangeDetails['connection'])) {
109
                throw new \RuntimeException(
110
                    sprintf(
111
                        "Could not create exchange %s: connection name %s is not defined!",
112
                        (string)$exchangeAliasName,
113
                        (string)$exchangeDetails['connection']
114
                    )
115
                );
116
            }
117
118
            $exchanges->put(
119
                $exchangeAliasName,
120
                ExchangeEntity::createExchange(
121
                    $connections->get($exchangeDetails['connection']),
122
                    $exchangeAliasName,
123
                    array_merge($exchangeDetails['attributes'], ['name' => $exchangeDetails['name']])
124
                )
125
            );
126
        }
127
        return $exchanges;
128
    }
129
130
    /**
131
     * @param array $queueConfigList
@@ 135-161 (lines=27) @@
132
     * @param Collection $connections
133
     * @return Collection
134
     */
135
    private function createQueues(array $queueConfigList, Collection $connections): Collection
136
    {
137
        $queue = new Collection();
138
        foreach ($queueConfigList as $queueAliasName => $queueDetails) {
139
            // verify if the connection exists
140
            if (array_key_exists('connection', $queueDetails) &&
141
                false === $connections->has($queueDetails['connection'])) {
142
                throw new \RuntimeException(
143
                    sprintf(
144
                        "Could not create exchange %s: connection name %s is not defined!",
145
                        (string)$queueAliasName,
146
                        (string)$queueDetails['connection']
147
                    )
148
                );
149
            }
150
151
            $queue->put(
152
                $queueAliasName,
153
                QueueEntity::createQueue(
154
                    $connections->get($queueDetails['connection']),
155
                    $queueAliasName,
156
                    array_merge($queueDetails['attributes'], ['name' => $queueDetails['name']])
157
                )
158
            );
159
        }
160
        return $queue;
161
    }
162
}
163