Code Duplication    Length = 20-23 lines in 2 locations

src/Kunstmaan/DashboardBundle/Command/GoogleAnalyticsDataCollectCommand.php 1 location

@@ 237-259 (lines=23) @@
234
     *
235
     * @return array
236
     */
237
    private function getAllOverviews()
238
    {
239
        $configRepository = $this->em->getRepository(AnalyticsConfig::class);
240
        $overviewRepository = $this->em->getRepository(AnalyticsOverview::class);
241
        $segmentRepository = $this->em->getRepository(AnalyticsSegment::class);
242
        $configs = $configRepository->findAll();
243
244
        foreach ($configs as $config) {
245
            // add overviews if none exist yet
246
            if (\count($config->getOverviews()) == 0) {
247
                $overviewRepository->addOverviews($config);
248
            }
249
250
            // init all the segments for this config
251
            $segments = $config->getSegments();
252
            foreach ($segments as $segment) {
253
                $segmentRepository->initSegment($segment);
254
            }
255
        }
256
257
        // get all overviews
258
        return $overviewRepository->findAll();
259
    }
260
261
    /**
262
     * update the overviews

src/Kunstmaan/DashboardBundle/Command/GoogleAnalyticsOverviewsGenerateCommand.php 1 location

@@ 165-184 (lines=20) @@
162
     *
163
     * @return array
164
     */
165
    private function generateAllOverviews()
166
    {
167
        $configRepository = $this->em->getRepository(AnalyticsConfig::class);
168
        $overviewRepository = $this->em->getRepository(AnalyticsOverview::class);
169
        $segmentRepository = $this->em->getRepository(AnalyticsSegment::class);
170
        $configs = $configRepository->findAll();
171
172
        foreach ($configs as $config) {
173
            // add overviews if none exist yet
174
            if (!\count($configRepository->findDefaultOverviews($config))) {
175
                $overviewRepository->addOverviews($config);
176
            }
177
178
            // init all the segments for this config
179
            $segments = $config->getSegments();
180
            foreach ($segments as $segment) {
181
                $segmentRepository->initSegment($segment);
182
            }
183
        }
184
    }
185
}
186