Passed
Push — master ( 768fdf...2d8d21 )
by Greg
02:29
created

Export::writeRow()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 2
dl 0
loc 3
rs 10
c 0
b 0
f 0
1
<?php
2
namespace GJClasses;
3
4
class Export
5
{
6
7
    public function openFile($base_filename, $append_data)
8
    {
9
        header('Content-Encoding: UTF-8');
10
        header('Content-Type: text/csv; charset=UTF-8');
11
        header("Content-Disposition: attachment; filename=\"" . $base_filename . "_" . $append_data . ".csv\"");
12
        header('Content-Transfer-Encoding: binary');
13
        header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
14
        header("Pragma: no-cache");
15
16
        $open_file = fopen('php://output', 'w');
17
        fprintf($open_file, chr(0xEF) . chr(0xBB) . chr(0xBF));
0 ignored issues
show
Bug introduced by
It seems like $open_file can also be of type false; however, parameter $handle of fprintf() does only seem to accept resource, maybe add an additional type check? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

17
        fprintf(/** @scrutinizer ignore-type */ $open_file, chr(0xEF) . chr(0xBB) . chr(0xBF));
Loading history...
18
19
        return $open_file;
20
    }
21
22
    public function writeRow($open_file, $row_contents)
23
    {
24
        fputcsv($open_file, $row_contents);
25
    }
26
27
    public function writeBlankRow($open_file)
28
    {
29
        $blank_line = array('');
30
        fputcsv($open_file, $blank_line);
31
    }
32
33
    public function closeFile($open_file)
34
    {
35
        fclose($open_file);
36
        return exit;
37
    }
38
39
}
40