Code Duplication    Length = 13-34 lines in 2 locations

src/Kunstmaan/DashboardBundle/Command/Helper/Analytics/ChartDataCommandHelper.php 1 location

@@ 62-74 (lines=13) @@
59
            }
60
61
            // timestamp
62
            if ($timespan <= 1) {
63
                $timestamp = mktime($row[1], 0, 0, substr($row[0], 4, 2), substr($row[0], 6, 2), substr($row[0], 0, 4));
64
                $timestamp = date('Y-m-d H:00', $timestamp);
65
            } elseif ($timespan <= 7) {
66
                $timestamp = mktime($row[1], 0, 0, substr($row[0], 4, 2), substr($row[0], 6, 2), substr($row[0], 0, 4));
67
                $timestamp = date('Y-m-d H:00', $timestamp);
68
            } elseif ($timespan <= 31) {
69
                $timestamp = mktime(0, 0, 0, substr($row[2], 4, 2), substr($row[2], 6, 2), substr($row[2], 0, 4));
70
                $timestamp = date('Y-m-d H:00', $timestamp);
71
            } else {
72
                $timestamp = strtotime(substr($row[0], 0, 4) . 'W' . substr($row[0], 4, 2));
73
                $timestamp = date('Y-m-d H:00', $timestamp);
74
            }
75
76
            // add to chart array
77
            $chartEntry = [

src/Kunstmaan/DashboardBundle/Command/Helper/Analytics/GoalCommandHelper.php 1 location

@@ 145-178 (lines=34) @@
142
            $goalEntry = [];
143
            foreach ($rows as $row) {
144
                // Create a timestamp for each goal visit (this depends on the timespan of the overview: split per hour, day, week, month)
145
                if ($timespan <= 1) {
146
                    $timestamp = mktime(
147
                        $row[1],
148
                        0,
149
                        0,
150
                        substr($row[0], 4, 2),
151
                        substr($row[0], 6, 2),
152
                        substr($row[0], 0, 4)
153
                    );
154
                    $timestamp = date('Y-m-d H:00', $timestamp);
155
                } elseif ($timespan <= 7) {
156
                    $timestamp = mktime(
157
                        $row[1],
158
                        0,
159
                        0,
160
                        substr($row[0], 4, 2),
161
                        substr($row[0], 6, 2),
162
                        substr($row[0], 0, 4)
163
                    );
164
                    $timestamp = date('Y-m-d H:00', $timestamp);
165
                } elseif ($timespan <= 31) {
166
                    $timestamp = mktime(
167
                        0,
168
                        0,
169
                        0,
170
                        substr($row[2], 4, 2),
171
                        substr($row[2], 6, 2),
172
                        substr($row[2], 0, 4)
173
                    );
174
                    $timestamp = date('Y-m-d H:00', $timestamp);
175
                } else {
176
                    $timestamp = strtotime(substr($row[0], 0, 4) . 'W' . substr($row[0], 4, 2));
177
                    $timestamp = date('Y-m-d H:00', $timestamp);
178
                }
179
                $goalEntry[$timestamp] = $row[$i + $start];
180
            }
181
            $goalCollection['goal' . $goaldata[$i]['position']]['name'] = $goaldata[$i]['name'];