Code Coverage |
||||||||||||||||
Lines |
Branches |
Paths |
Functions and Methods |
Classes and Traits |
||||||||||||
| Total | |
100.00% |
6 / 6 |
|
100.00% |
6 / 6 |
|
100.00% |
6 / 6 |
|
100.00% |
6 / 6 |
CRAP | |
100.00% |
1 / 1 |
| RandomWordRequest | |
100.00% |
6 / 6 |
|
100.00% |
6 / 6 |
|
100.00% |
6 / 6 |
|
100.00% |
6 / 6 |
6 | |
100.00% |
1 / 1 |
| __construct | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| getPreviousId | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| getGrammaticalRoleType | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| getGender | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| getOffenseLevel | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| getExclusions | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| 1 | <?php |
| 2 | |
| 3 | namespace App\Dto\Request; |
| 4 | |
| 5 | use App\Enum\GrammaticalRoleType; |
| 6 | use App\Enum\OffenseLevel; |
| 7 | use App\Enum\WordGender; |
| 8 | use App\Exception\ValidationErrorMessage; |
| 9 | use Symfony\Component\Validator\Constraints as Assert; |
| 10 | |
| 11 | /** |
| 12 | * @author Wilhelm Zwertvaegher |
| 13 | * Parameters for word retrieval (i.e. replace a word in a generated nick) |
| 14 | * - Lang |
| 15 | * - WordType |
| 16 | * - OffenseLevel (maybe null) |
| 17 | * - WordGender (maybe null) |
| 18 | * - exclusions : a list a word ids to exclude |
| 19 | */ |
| 20 | class RandomWordRequest implements Request |
| 21 | { |
| 22 | /** |
| 23 | * @param list<int> $exclusions |
| 24 | */ |
| 25 | public function __construct( |
| 26 | #[Assert\Type('integer', message: ValidationErrorMessage::INVALID_FIELD_VALUE)] |
| 27 | private int $previousId, |
| 28 | private GrammaticalRoleType $role, |
| 29 | private WordGender $gender, |
| 30 | private OffenseLevel $offenseLevel = OffenseLevel::MEDIUM, |
| 31 | private array $exclusions = [], |
| 32 | ) { |
| 33 | } |
| 34 | |
| 35 | public function getPreviousId(): int |
| 36 | { |
| 37 | return $this->previousId; |
| 38 | } |
| 39 | |
| 40 | public function getGrammaticalRoleType(): GrammaticalRoleType |
| 41 | { |
| 42 | return $this->role; |
| 43 | } |
| 44 | |
| 45 | public function getGender(): ?WordGender |
| 46 | { |
| 47 | return $this->gender; |
| 48 | } |
| 49 | |
| 50 | public function getOffenseLevel(): ?OffenseLevel |
| 51 | { |
| 52 | return $this->offenseLevel; |
| 53 | } |
| 54 | |
| 55 | /** |
| 56 | * @return list<int> |
| 57 | */ |
| 58 | public function getExclusions(): array |
| 59 | { |
| 60 | return $this->exclusions; |
| 61 | } |
| 62 | } |