1 | <?php |
||||
2 | |||||
3 | /** |
||||
4 | * This file is part of the bugloos/export-bundle project. |
||||
5 | * (c) Bugloos <https://bugloos.com/> |
||||
6 | * For the full copyright and license information, please view |
||||
7 | * the LICENSE file that was distributed with this source code. |
||||
8 | */ |
||||
9 | |||||
10 | namespace Bugloos\ExportBundle\Services; |
||||
11 | |||||
12 | use Bugloos\ExportBundle\Contracts\ExporterInterface; |
||||
13 | use Bugloos\ExportBundle\Factory\ResponseFactory; |
||||
14 | use Bugloos\ExportBundle\Writer; |
||||
15 | use Symfony\Component\HttpFoundation\Response; |
||||
16 | |||||
17 | /** |
||||
18 | * @author Mojtaba Gheytasi <[email protected] | [email protected]> |
||||
19 | */ |
||||
20 | class Excel implements ExporterInterface |
||||
21 | { |
||||
22 | public const XLSX = 'Xlsx'; |
||||
23 | |||||
24 | public const CSV = 'Csv'; |
||||
25 | |||||
26 | public function download( |
||||
27 | $exportClass, |
||||
28 | string $fileName, |
||||
29 | string $writerType = null, |
||||
30 | array $headers = [] |
||||
31 | ): Response { |
||||
32 | |||||
33 | $output = (new Writer())->export($exportClass, $writerType); |
||||
0 ignored issues
–
show
Bug
introduced
by
![]() |
|||||
34 | |||||
35 | $fileName = $fileName.'.'.$this->makeFileNameExtension($writerType); |
||||
36 | |||||
37 | return (new ResponseFactory())->makeResponse($writerType, $output, $fileName); |
||||
0 ignored issues
–
show
It seems like
$writerType can also be of type null ; however, parameter $exportFormat of Bugloos\ExportBundle\Fac...Factory::makeResponse() does only seem to accept string , 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
![]() |
|||||
38 | } |
||||
39 | |||||
40 | public function makeFileNameExtension($writerType): string |
||||
41 | { |
||||
42 | return lcfirst($writerType); |
||||
43 | } |
||||
44 | } |
||||
45 |