Passed
Push — master ( d7e8d7...5cd27e )
by
unknown
26:58 queued 24:20
created

ConfigReader   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 23
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 6
c 1
b 0
f 0
dl 0
loc 23
rs 10
wmc 3

2 Methods

Rating   Name   Duplication   Size   Complexity  
A getBasePath() 0 3 1
A get() 0 9 2
1
<?php
2
3
namespace Da\Mailer\Helper;
4
5
use Exception;
6
7
class ConfigReader
8
{
9
    /**
10
     * @return array
11
     * @throws Exception
12
     */
13
    public static function get(): array
14
    {
15
        $configPath = require self::getBasePath() . 'config/mailer.php';
16
17
        if (! is_array($configPath)) {
18
            throw new Exception('The configuration format is invalid. It must be an array!');
19
        }
20
21
        return $configPath;
22
    }
23
24
    /**
25
     * @return string
26
     */
27
    public static function getBasePath(): string
28
    {
29
        return __DIR__ . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR;
30
    }
31
}
32