Code Duplication    Length = 15-16 lines in 2 locations

src/Http/Controller/EntryController.php 1 location

@@ 145-159 (lines=15) @@
142
            'Expires'             => '0'
143
        ];
144
145
        $callback = function () {
146
147
            $output = fopen('php://output', 'w');
148
149
            foreach ($this->repository->all() as $k => $entry) {
150
151
                if ($k == 0) {
152
                    fputcsv($output, array_keys($entry->toArray()));
153
                }
154
155
                fputcsv($output, $entry->toArray());
156
            }
157
158
            fclose($output);
159
        };
160
161
        return $this->response->stream($callback, 200, $headers);
162
    }

src/Ui/Table/Component/Action/Handler/ExportAll.php 1 location

@@ 40-55 (lines=16) @@
37
            'Expires'             => '0'
38
        ];
39
40
        $callback = function () use ($selected, $model) {
41
42
            $output = fopen('php://output', 'w');
43
44
            /* @var EloquentModel $entry */
45
            foreach ($model->all() as $k => $entry) {
46
47
                if ($k == 0) {
48
                    fputcsv($output, array_keys($entry->toArray()));
49
                }
50
51
                fputcsv($output, $entry->toArray());
52
            }
53
54
            fclose($output);
55
        };
56
57
        $builder->setTableResponse($response->stream($callback, 200, $headers));
58
    }