Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
33.33% |
1 / 3 |
|
33.33% |
1 / 3 |
CRAP | |
0.00% |
0 / 1 |
| TemplateExport | |
33.33% |
1 / 3 |
|
33.33% |
1 / 3 |
5.67 | |
0.00% |
0 / 1 |
| __construct | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| headings | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| array | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| 1 | <?php |
| 2 | |
| 3 | namespace App\Services\ImportExport; |
| 4 | |
| 5 | use Maatwebsite\Excel\Concerns\FromArray; |
| 6 | use Maatwebsite\Excel\Concerns\WithHeadings; |
| 7 | |
| 8 | /** A blank import template: the headers plus one sample row. */ |
| 9 | class TemplateExport implements FromArray, WithHeadings |
| 10 | { |
| 11 | public function __construct(private readonly Definition $definition) {} |
| 12 | |
| 13 | public function headings(): array |
| 14 | { |
| 15 | return $this->definition->headings(); |
| 16 | } |
| 17 | |
| 18 | public function array(): array |
| 19 | { |
| 20 | return [array_values($this->definition->sampleRow())]; |
| 21 | } |
| 22 | } |