Code Duplication    Length = 20-23 lines in 2 locations

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

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

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

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