Completed
Push — master ( 695b53...13261c )
by Tomas
03:17
created

NotificationHistoryResolver::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace OneSignal\Resolver;
6
7
use OneSignal\Config;
8
use Symfony\Component\OptionsResolver\OptionsResolver;
9
10
class NotificationHistoryResolver implements ResolverInterface
11
{
12
    private $config;
13
14
    public function __construct(Config $config)
15
    {
16
        $this->config = $config;
17
    }
18
19
    /**
20
     * {@inheritdoc}
21
     */
22
    public function resolve(array $data): array
23
    {
24
        return (new OptionsResolver())
25
            ->setRequired('events')
26
            ->setAllowedTypes('events', 'string')
27
            ->setAllowedValues('events', ['sent', 'clicked'])
28
            ->setRequired('email')
29
            ->setAllowedTypes('email', 'string')
30
            ->setDefault('app_id', $this->config->getApplicationId())
31
            ->setAllowedTypes('app_id', 'string')
32
            ->resolve($data);
33
    }
34
}
35