NotificationHistoryResolver   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 25
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

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

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A resolve() 0 12 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