iDokladFactory   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 72
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Importance

Changes 0
Metric Value
wmc 3
lcom 0
cbo 2
dl 0
loc 72
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A create() 0 7 1
A getRequiredOptions() 0 13 1
A getAvailableOptions() 0 29 1
1
<?php
2
3
namespace Fousky\Component\iDoklad;
4
5
use Fousky\Component\iDoklad\Storage\AccessTokenStorageInterface;
6
7
/**
8
 * @author Lukáš Brzák <[email protected]>
9
 */
10
class iDokladFactory
11
{
12
    /**
13
     * @param array                            $config
14
     * @param AccessTokenStorageInterface|null $storage
15
     *
16
     * @throws \Symfony\Component\OptionsResolver\Exception\ExceptionInterface
17
     *
18
     * @return iDoklad
19
     */
20
    public static function create(array $config, AccessTokenStorageInterface $storage = null): iDoklad
21
    {
22
        return new iDoklad(
23
            $config,
24
            new iDokladTokenFactory($storage)
25
        );
26
    }
27
28
    /**
29
     * Get all required options for $config.
30
     *
31
     * @return array
32
     */
33
    public static function getRequiredOptions(): array
34
    {
35
        return [
36
            'client_id' => [
37
                'info' => 'Client ID from iDoklad admin.',
38
                'types' => ['string'],
39
            ],
40
            'client_secret' => [
41
                'info' => 'Client secret from iDoklad admin.',
42
                'types' => ['string'],
43
            ],
44
        ];
45
    }
46
47
    /**
48
     * Get all available options for $config.
49
     *
50
     * @return array
51
     */
52
    public static function getAvailableOptions(): array
53
    {
54
        return [
55
            'debug' => [
56
                'info' => 'If true, then GuzzleHttp will be in verbose mode.',
57
                'types' => ['boolean'],
58
            ],
59
            'url' => [
60
                'info' => 'iDoklad API base URL',
61
                'types' => ['string'],
62
            ],
63
            'token_endpoint' => [
64
                'info' => 'iDoklad Access Token URL',
65
                'types' => ['string'],
66
            ],
67
            'client_id' => [
68
                'info' => 'Client ID from iDoklad admin.',
69
                'types' => ['string'],
70
            ],
71
            'client_secret' => [
72
                'info' => 'Client secret from iDoklad admin.',
73
                'types' => ['string'],
74
            ],
75
            'scope' => [
76
                'info' => 'iDoklad scope configuration.',
77
                'types' => ['string'],
78
            ],
79
        ];
80
    }
81
}
82