DeviceSessionResolver   A
last analyzed

Complexity

Total Complexity 1

Size/Duplication

Total Lines 49
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Importance

Changes 0
Metric Value
wmc 1
lcom 0
cbo 1
dl 0
loc 49
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A resolve() 0 43 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace OneSignal\Resolver;
6
7
use OneSignal\Devices;
8
use Symfony\Component\OptionsResolver\OptionsResolver;
9
10
class DeviceSessionResolver implements ResolverInterface
11
{
12
    /**
13
     * {@inheritdoc}
14
     */
15
    public function resolve(array $data): array
16
    {
17
        return (new OptionsResolver())
18
            ->setDefined('identifier')
19
            ->setAllowedTypes('identifier', 'string')
20
            ->setDefined('language')
21
            ->setAllowedTypes('language', 'string')
22
            ->setDefined('timezone')
23
            ->setAllowedTypes('timezone', 'int')
24
            ->setDefined('game_version')
25
            ->setAllowedTypes('game_version', 'string')
26
            ->setDefined('device_os')
27
            ->setAllowedTypes('device_os', 'string')
28
            // @todo: remove "device_model" later (this option is probably deprecated as it is removed from documentation)
29
            ->setDefined('device_model')
30
            ->setAllowedTypes('device_model', 'string')
31
            ->setDefined('ad_id')
32
            ->setAllowedTypes('ad_id', 'string')
33
            ->setDefined('sdk')
34
            ->setAllowedTypes('sdk', 'string')
35
            ->setDefined('tags')
36
            ->setAllowedTypes('tags', 'array')
37
            ->setDefined('device_type')
38
            ->setAllowedTypes('device_type', 'int')
39
            ->setAllowedValues('device_type', [
40
                Devices::IOS,
41
                Devices::ANDROID,
42
                Devices::AMAZON,
43
                Devices::WINDOWS_PHONE,
44
                Devices::WINDOWS_PHONE_MPNS,
45
                Devices::CHROME_APP,
46
                Devices::CHROME_WEB,
47
                Devices::WINDOWS_PHONE_WNS,
48
                Devices::SAFARI,
49
                Devices::FIREFOX,
50
                Devices::MACOS,
51
                Devices::ALEXA,
52
                Devices::EMAIL,
53
                Devices::HUAWEI,
54
                Devices::SMS,
55
            ])
56
            ->resolve($data);
57
    }
58
}
59