Config::__construct()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 13
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 2
eloc 4
nc 2
nop 4
dl 0
loc 13
rs 10
c 1
b 0
f 0
1
<?php
2
3
declare(strict_types=1);
4
5
namespace AbterPhp\Framework\Exception;
6
7
use Throwable;
8
9
class Config extends \LogicException
10
{
11
    protected const ERROR_MSG        = 'Insufficient configs found while resolving dependency: %s';
12
    protected const REQUIRED_CONFIGS = ' (Related environment variables: %s)';
13
14
    /**
15
     * Config constructor.
16
     *
17
     * @param string         $className
18
     * @param array          $relatedEnvVars
19
     * @param int            $code
20
     * @param Throwable|null $previous
21
     */
22
    public function __construct(
23
        string $className,
24
        array $relatedEnvVars = [],
25
        int $code = 0,
26
        Throwable $previous = null
27
    ) {
28
        $message = sprintf(static::ERROR_MSG, $className);
29
30
        if (!empty($relatedEnvVars)) {
31
            $message .= sprintf(static::REQUIRED_CONFIGS, implode(', ', $relatedEnvVars));
32
        }
33
34
        parent::__construct($message, $code, $previous);
35
    }
36
}
37