Lines 100.00% 9 / 9
Functions and Methods 100.00% 1 / 1
Classes and Traits 100.00% 1 / 1
Name Lines Functions and Methods CRAP Classes and Traits
StatsImportType 100.00% 9 / 9 100.00% 1 / 1 1 100.00% 1 / 1
 buildForm 100.00% 9 / 9 100.00% 1 / 1 1
1<?php
2
3declare(strict_types=1);
4
5namespace App\Form;
6
7use Symfony\Component\Form\AbstractType;
8use Symfony\Component\Form\Extension\Core\Type\FileType;
9use Symfony\Component\Form\FormBuilderInterface;
10use Symfony\Component\Validator\Constraints\File;
11use Symfony\Component\Validator\Constraints\NotNull;
12
13/**
14 * A CSV file of agent stats (App\Import\AgentStatCsvImporter) or a JSON file of custom medals
15 * (App\Import\CustomMedalsJsonImporter), on /agent-stats/import.
16 */
17class StatsImportType extends AbstractType
18{
19    public function buildForm(FormBuilderInterface $builder, array $options): void
20    {
21        $builder->add('file', FileType::class, [
22            'label' => 'stats_import.file',
23            'help' => 'stats_import.file_help',
24            'attr' => ['accept' => '.csv,text/csv,.json,application/json'],
25            'constraints' => [
26                new NotNull(message: 'stats_import.no_file'),
27                new File(maxSize: '5M', extensions: ['csv', 'txt', 'json']),
28            ],
29        ]);
30    }
31}