AuthenticationProvider   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 28
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 4

Importance

Changes 2
Bugs 1 Features 0
Metric Value
wmc 2
c 2
b 1
f 0
lcom 0
cbo 4
dl 0
loc 28
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A get() 0 19 2
1
<?php
2
3
/**
4
 * Class AuthenticationProvider
5
 */
6
7
namespace HDNET\OnpageIntegration\Provider;
8
9
use HDNET\OnpageIntegration\Domain\Repository\ConfigurationRepository;
10
use HDNET\OnpageIntegration\Exception\UnavailableAccessDataException;
11
use TYPO3\CMS\Extbase\Object\ObjectManager;
12
use TYPO3\CMS\Extbase\Utility\DebuggerUtility;
13
14
/**
15
 * Class AuthenticationProvider
16
 */
17
class AuthenticationProvider extends AbstractProvider
18
{
19
20
    /**
21
     * Build the authentication index for an api call
22
     *
23
     * @return array
24
     */
25
    public function get()
26
    {
27
        $objectManager = new ObjectManager();
28
        $configurationRepository = $objectManager->get(ConfigurationRepository::class);
29
30
        /** @var \HDNET\OnpageIntegration\Domain\Model\Configuration $configuration */
31
        $configuration = $configurationRepository->findRecord(1);
32
33
        if (!$configuration) {
34
            throw new UnavailableAccessDataException;
35
        }
36
37
        $buildAuth = [
38
            'api_key' => $configuration->getApiKey(),
39
            'project' => $configuration->getProjectId(),
40
        ];
41
42
        return $buildAuth;
43
    }
44
}
45