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

Service/Command/Exporter/Exporter.php (2 issues)

Upgrade to new PHP Analysis Engine

These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more

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
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
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