Passed
Push — features/addFlushedPagesToCraw... ( 44f5f4...d700c8 )
by Tomas Norre
08:39
created

ExtensionConfigurationProvider   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 15
Duplicated Lines 0 %

Test Coverage

Coverage 33.33%

Importance

Changes 0
Metric Value
eloc 8
dl 0
loc 15
ccs 2
cts 6
cp 0.3333
rs 10
c 0
b 0
f 0
wmc 3

1 Method

Rating   Name   Duplication   Size   Complexity  
A getExtensionConfiguration() 0 8 3
1
<?php
2
3
declare(strict_types=1);
4
5
namespace AOE\Crawler\Configuration;
6
7
 /*
8
 * (c) 2020 AOE GmbH <[email protected]>
9
 *
10
 * This file is part of the TYPO3 Crawler Extension.
11
 *
12
 * It is free software; you can redistribute it and/or modify it under
13
 * the terms of the GNU General Public License, either version 2
14
 * of the License, or any later version.
15
 *
16
 * For the full copyright and license information, please read the
17
 * LICENSE.txt file that was distributed with this source code.
18
 *
19
 * The TYPO3 project - inspiring people to share!
20
 */
21
22
use Psr\Log\LoggerAwareInterface;
23
use Psr\Log\LoggerAwareTrait;
24
use TYPO3\CMS\Core\Configuration\Exception\ExtensionConfigurationExtensionNotConfiguredException;
25
use TYPO3\CMS\Core\Configuration\Exception\ExtensionConfigurationPathDoesNotExistException;
26
use TYPO3\CMS\Core\Configuration\ExtensionConfiguration;
27
use TYPO3\CMS\Core\Utility\GeneralUtility;
28
29
class ExtensionConfigurationProvider implements LoggerAwareInterface
30
{
31
    use LoggerAwareTrait;
32
33
    /**
34
     * Return full extension configuration array.
35
     */
36 82
    public function getExtensionConfiguration(): array
37
    {
38
        try {
39 82
            return GeneralUtility::makeInstance(ExtensionConfiguration::class)->get('crawler');
40
        } catch (ExtensionConfigurationExtensionNotConfiguredException $e) {
41
            $this->logger->error($e->getMessage());
0 ignored issues
show
Bug Best Practice introduced by
In this branch, the function will implicitly return null which is incompatible with the type-hinted return array. Consider adding a return statement or allowing null as return value.

For hinted functions/methods where all return statements with the correct type are only reachable via conditions, ?null? gets implicitly returned which may be incompatible with the hinted type. Let?s take a look at an example:

interface ReturnsInt {
    public function returnsIntHinted(): int;
}

class MyClass implements ReturnsInt {
    public function returnsIntHinted(): int
    {
        if (foo()) {
            return 123;
        }
        // here: null is implicitly returned
    }
}
Loading history...
42
        } catch (ExtensionConfigurationPathDoesNotExistException $e) {
43
            $this->logger->error($e->getMessage());
44
        }
45
    }
46
}
47