GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.

Handler::create()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 3
1
<?php
2
3
namespace Sigmapix\Sonata\ImportBundle\Export;
4
5
use Exporter\Source\SourceIteratorInterface;
6
use Exporter\Writer\WriterInterface;
7
8
class Handler
9
{
10
    /**
11
     * @var SourceIteratorInterface
12
     */
13
    protected $source;
14
15
    /**
16
     * @var WriterInterface
17
     */
18
    protected $writer;
19
20
    /**
21
     * @var array
22
     */
23
    protected $defaultHeaders;
24
25
    /**
26
     * @param SourceIteratorInterface $source
27
     * @param WriterInterface         $writer
28
     */
29
    public function __construct(SourceIteratorInterface $source, WriterInterface $writer, array $defaultHeaders = [])
30
    {
31
        $this->source = $source;
32
        $this->writer = $writer;
33
        $this->defaultHeaders = $defaultHeaders;
34
    }
35
36
    public function export()
37
    {
38
        $exportData = [];
39
        foreach ($this->source as $data) {
40
            $exportData[] = $data;
41
        }
42
43
        $this->writer->open();
44
45
        if (empty($exportData) && !empty($this->defaultHeaders)) {
46
            $this->writer->write($this->defaultHeaders);
47
        } else {
48
            foreach ($exportData as $data) {
49
                $this->writer->write($data);
50
            }
51
        }
52
53
        $this->writer->close();
54
    }
55
56
    /**
57
     * @param SourceIteratorInterface $source
58
     * @param WriterInterface         $writer
59
     *
60
     * @return Handler
61
     */
62
    public static function create(SourceIteratorInterface $source, WriterInterface $writer, array $defaultHeaders = [])
63
    {
64
        return new self($source, $writer, $defaultHeaders);
65
    }
66
}
67