Config   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 26
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 7
dl 0
loc 26
rs 10
c 1
b 0
f 0
wmc 2

1 Method

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 13 2
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