AuthenticationProvider::get()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 19
Code Lines 10

Duplication

Lines 0
Ratio 0 %

Importance

Changes 2
Bugs 1 Features 0
Metric Value
c 2
b 1
f 0
dl 0
loc 19
rs 9.4285
cc 2
eloc 10
nc 2
nop 0
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