Test Failed
Push — develop ( 33b521...cdbd76 )
by Paul
10:16 queued 21s
created

GeolocationDefaults   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 55
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 1
eloc 25
c 1
b 0
f 0
dl 0
loc 55
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A defaults() 0 10 1
1
<?php
2
3
namespace GeminiLabs\SiteReviews\Defaults;
4
5
class GeolocationDefaults extends DefaultsAbstract
6
{
7
    /**
8
     * The values that should be constrained after sanitization is run.
9
     * This is done after $casts and $sanitize.
10
     */
11
    public array $enums = [
12
        'status' => [
13
            'fail', 'success',
14
        ],
15
    ];
16
17
    /**
18
     * The values that should be guarded.
19
     *
20
     * @var string[]
21
     */
22
    public array $guarded = [
23
        'message', 'query', 'status',
24
    ];
25
26
    /**
27
     * The keys that should be mapped to other keys.
28
     * Keys are mapped before the values are normalized and sanitized.
29
     * Note: Mapped keys should not be included in the defaults!
30
     */
31
    public array $mapped = [
32
        'continentCode' => 'continent',
33
        'countryCode' => 'country',
34
    ];
35
36
    /**
37
     * The values that should be sanitized.
38
     * This is done after $casts and before $enums.
39
     */
40
    public array $sanitize = [
41
        'city' => 'text',
42
        'continent' => 'text',
43
        'country' => 'text',
44
        'message' => 'text',
45
        'query' => 'text',
46
        'region' => 'text',
47
        'status' => 'text',
48
    ];
49
50
    protected function defaults(): array
51
    {
52
        return [
53
            'city' => '',
54
            'continent' => '',
55
            'country' => '',
56
            'message' => '', // included only when status is fail
57
            'query' => '', // the submitted IP address
58
            'region' => '',
59
            'status' => 'fail',
60
        ];
61
    }
62
}
63