Passed
Push — main ( 057454...9ca083 )
by Karl
05:44
created

GameFormValidator::isValidForm()   A

Complexity

Conditions 3
Paths 3

Size

Total Lines 6
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 3
eloc 4
c 1
b 0
f 0
nc 3
nop 1
dl 0
loc 6
rs 10
1
<?php
2
3
namespace App\Model;
4
5
use Exception;
6
7
class GameFormValidator
8
{
9
    private const VALID_FORM_NAMES = ['action', 'bet'];
10
11
    /**
12
     * Validates the form data.
13
     *
14
     * @param array<string, string> $formData The form data to validate.
15
     *
16
     * @throws Exception If an invalid form name is found.
17
     */
18
    public function isValidForm(array $formData): void
19
    {
20
        $formKeys = array_keys($formData);
21
        foreach ($formKeys as $key) {
22
            if (!in_array($key, self::VALID_FORM_NAMES)) {
23
                throw new Exception('Invalid form name.');
24
            }
25
26
            // ignorantly accepting all values...
27
        }
28
    }
29
}
30