PhpSetting   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 29
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Importance

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

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 12 2
A getIniPath() 0 4 1
1
<?php
2
declare(strict_types=1);
3
4
namespace Crossjoin\Browscap\Source\Ini;
5
6
use Crossjoin\Browscap\Exception\SourceConditionNotSatisfiedException;
7
use Crossjoin\Browscap\Exception\SourceUnavailableException;
8
use Crossjoin\Browscap\Source\SourceFactoryInterface;
9
10
/**
11
 * Class PhpSetting
12
 *
13
 * @package Crossjoin\Browscap\Source\Ini
14
 * @author Christoph Ziegenberg <[email protected]>
15
 * @link https://github.com/crossjoin/browscap
16
 */
17
class PhpSetting extends File implements SourceFactoryInterface
18
{
19
    /**
20
     * PhpBrowscapIni constructor.
21
     *
22
     * @throws SourceConditionNotSatisfiedException
23
     * @throws SourceUnavailableException
24
     */
25
    public function __construct()
26
    {
27
        $iniPath = $this->getIniPath();
28
        if ($iniPath !== '') {
29
            parent::__construct($iniPath);
30
        } else {
31
            throw new SourceConditionNotSatisfiedException(
32
                "Browscap file not configured in php configuration (see 'browscap' directive).",
33
                1458977060
34
            );
35
        }
36
    }
37
38
    /**
39
     * @return string
40
     */
41
    protected function getIniPath() : string
42
    {
43
        return (string)ini_get('browscap');
44
    }
45
}
46