Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
100.00% covered (success)
100.00%
4 / 4
100.00% covered (success)
100.00%
3 / 3
CRAP
100.00% covered (success)
100.00%
1 / 1
MaxfieldCreateType
100.00% covered (success)
100.00%
4 / 4
100.00% covered (success)
100.00%
3 / 3
4
100.00% covered (success)
100.00%
1 / 1
 getPoints
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 getPlayersNum
100.00% covered (success)
100.00%
2 / 2
100.00% covered (success)
100.00%
1 / 1
2
 getProjectName
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
1<?php
2
3declare(strict_types=1);
4
5namespace App\Type;
6
7use Symfony\Component\String\Slugger\AsciiSlugger;
8
9final class MaxfieldCreateType
10{
11    public string $points;
12
13    public string $buildName;
14
15    /**
16     * @todo can not type hint this :(
17     * @see https://github.com/symfony/symfony/issues/50759
18     */
19    public mixed $playersNum = null;
20
21    public bool $skipPlots = false;
22
23    public bool $skipStepPlots = false;
24
25    /**
26     * @return array<int>
27     */
28    public function getPoints(): array
29    {
30        return array_map(intval(...), explode(',', $this->points));
31    }
32
33    public function getPlayersNum(): int
34    {
35        /** @var int|string|null $num */
36        $num = $this->playersNum;
37
38        return $num ? (int) $num : 1;
39    }
40
41    public function getProjectName(): string
42    {
43        return uniqid().'-'.new AsciiSlugger()->slug($this->buildName);
44    }
45}