Test Failed
Push — master ( d28b9e...d373cf )
by Julien
18:34 queued 14:17
created

Config::pathToArray()   A

Complexity

Conditions 3
Paths 3

Size

Total Lines 13
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 3
eloc 6
c 1
b 0
f 0
nc 3
nop 3
dl 0
loc 13
rs 10
1
<?php
2
3
/**
4
 * This file is part of the Zemit Framework.
5
 *
6
 * (c) Zemit Team <[email protected]>
7
 *
8
 * For the full copyright and license information, please view the LICENSE.txt
9
 * file that was distributed with this source code.
10
 */
11
12
namespace Zemit\Config;
13
14
class Config extends \Phalcon\Config implements ConfigInterface
15
{
16
    /**
17
     * Return the element as an array
18
     */
19
    public function pathToArray(string $path, ?array $defaultValue = null, ?string $delimiter = null): ?array
20
    {
21
        $ret = $this->path($path, $defaultValue, $delimiter);
22
        
23
        if (is_null($ret)) {
24
            return null;
25
        }
26
        
27
        if ($ret instanceof \Phalcon\Config) {
28
            return $ret->toArray();
29
        }
30
        
31
        return (array)$ret;
32
    }
33
    
34
    /**
35
     * Return the mapped model class name from $this->models->$class
36
     */
37
    public function getModelClass(string $class): string
38
    {
39
        return $this->get('models')->get($class) ?: $class;
40
    }
41
    
42
    /**
43
     * Map a new model class
44
     */
45
    public function setModelClass(string $class, string $expected): void
46
    {
47
        $this->get('models')->set($class, $expected);
48
    }
49
    
50
    /**
51
     * Map a new model class
52
     */
53
    public function resetModelClass(string $class): void
54
    {
55
        $this->get('models')->set($class, $class);
56
    }
57
}
58