Completed
Push — typo3v9 ( aa4a41...31f403 )
by Tomas Norre
06:40
created

PhpBinaryUtility   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 22
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Test Coverage

Coverage 61.53%

Importance

Changes 0
Metric Value
dl 0
loc 22
ccs 8
cts 13
cp 0.6153
rs 10
c 0
b 0
f 0
wmc 3
lcom 0
cbo 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A getPhpBinary() 0 16 3
1
<?php
2
declare(strict_types=1);
3
namespace AOE\Crawler\Utility;
4
5
/*
6
 * (c) 2019 AOE GmbH <[email protected]>
7
 *
8
 * This file is part of the TYPO3 Crawler Extension.
9
 *
10
 * It is free software; you can redistribute it and/or modify it under
11
 * the terms of the GNU General Public License, either version 2
12
 * of the License, or any later version.
13
 *
14
 * For the full copyright and license information, please read the
15
 * LICENSE.txt file that was distributed with this source code.
16
 *
17
 * The TYPO3 project - inspiring people to share!
18
 */
19
20
use AOE\Crawler\Configuration\ExtensionConfigurationProvider;
21
use TYPO3\CMS\Core\Utility\CommandUtility;
22
use TYPO3\CMS\Core\Utility\GeneralUtility;
23
24
class PhpBinaryUtility
25
{
26
    /**
27
     * @return string
28
     */
29 2
    public static function getPhpBinary(): string
30
    {
31 2
        $extensionSettings = GeneralUtility::makeInstance(ExtensionConfigurationProvider::class)->getExtensionConfiguration();
32
33 2
        if (empty($extensionSettings)) {
34 1
            throw new \Exception('ExtensionSettings are empty');
35
        }
36
37 1
        if (empty($extensionSettings['phpPath'])) {
38 1
            $phpPath = CommandUtility::getCommand($extensionSettings['phpBinary']);
39
        } else {
40 1
            $phpPath = $extensionSettings['phpPath'];
41
        }
42
43 1
        return $phpPath;
44
    }
45
}
46