Completed
Push — master ( 6fb51e...94364b )
by Thierry
01:40
created

Php   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 25
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Importance

Changes 0
Metric Value
dl 0
loc 25
rs 10
c 0
b 0
f 0
wmc 3
lcom 0
cbo 1

1 Method

Rating   Name   Duplication   Size   Complexity  
A read() 0 15 3
1
<?php
2
3
/**
4
 * Php.php - Jaxon config reader
5
 *
6
 * Read the config data from a PHP config file.
7
 *
8
 * @package jaxon-core
9
 * @author Thierry Feuzeu <[email protected]>
10
 * @copyright 2016 Thierry Feuzeu <[email protected]>
11
 * @license https://opensource.org/licenses/BSD-3-Clause BSD 3-Clause License
12
 * @link https://github.com/jaxon-php/jaxon-core
13
 */
14
15
namespace Jaxon\Config;
16
17
class Php
18
{
19
    /**
20
     * Read options from a PHP config file
21
     *
22
     * @param string        $sConfigFile        The full path to the config file
23
     *
24
     * @return array
25
     */
26
    public static function read($sConfigFile)
27
    {
28
        $sConfigFile = realpath($sConfigFile);
29
        if(!is_readable($sConfigFile))
30
        {
31
            throw new \Jaxon\Config\Exception\File(jaxon_trans('config.errors.file.access', array('path' => $sConfigFile)));
32
        }
33
        $aConfigOptions = include($sConfigFile);
34
        if(!is_array($aConfigOptions))
35
        {
36
            throw new \Jaxon\Config\Exception\File(jaxon_trans('config.errors.file.content', array('path' => $sConfigFile)));
37
        }
38
39
        return $aConfigOptions;
40
    }
41
}
42