Completed
Pull Request — 5.6 (#2830)
by Jeroen
14:14
created

Exporter   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 30
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Test Coverage

Coverage 80%

Importance

Changes 0
Metric Value
wmc 5
lcom 1
cbo 1
dl 0
loc 30
ccs 8
cts 10
cp 0.8
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A getExportedContent() 0 4 1
A getExporterByExtension() 0 10 3
A setExporters() 0 4 1
1
<?php
2
3
namespace Kunstmaan\TranslatorBundle\Service\Command\Exporter;
4
5
use Kunstmaan\TranslatorBundle\Model\Export\ExportFile;
6
7
/**
8
 * Responsible for exporting translations into files
9
 */
10
class Exporter
11
{
12
    /**
13
     * Array of all translation exporter
14
     *
15
     * @var array
16
     */
17
    private $exporters = [];
18
19
    public function getExportedContent(ExportFile $exportFile)
0 ignored issues
show
Documentation introduced by
The return type could not be reliably inferred; please add a @return annotation.

Our type inference engine in quite powerful, but sometimes the code does not provide enough clues to go by. In these cases we request you to add a @return annotation as described here.

Loading history...
20
    {
21
        return $this->getExporterByExtension($exportFile->getExtension())->export($exportFile->getArray());
22
    }
23
24 2
    public function getExporterByExtension($extension)
0 ignored issues
show
Documentation introduced by
The return type could not be reliably inferred; please add a @return annotation.

Our type inference engine in quite powerful, but sometimes the code does not provide enough clues to go by. In these cases we request you to add a @return annotation as described here.

Loading history...
25
    {
26 2
        foreach ($this->exporters as $exporter) {
27 2
            if ($exporter->supports($extension)) {
28 1
                return $exporter;
29
            }
30
        }
31
32 1
        throw new \Exception(sprintf('No %s file exporter found or defined.', $extension));
33
    }
34
35 2
    public function setExporters($exporters)
36
    {
37 2
        $this->exporters = $exporters;
38 2
    }
39
}
40