LoaderLoadException   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 33
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Importance

Changes 0
Metric Value
wmc 5
lcom 0
cbo 0
dl 0
loc 33
rs 10
c 0
b 0
f 0

4 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 6 1
A getResource() 0 4 1
A getType() 0 4 1
A composeMessage() 0 10 2
1
<?php
2
3
/*
4
 * This file is part of the Yosymfony config-loader.
5
 *
6
 * (c) YoSymfony <http://github.com/yosymfony>
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
12
namespace Yosymfony\ConfigLoader\Exception;
13
14
/**
15
 * Exception loading a loader
16
 */
17
class LoaderLoadException extends \RuntimeException
18
{
19
    private $resource;
20
    private $type;
21
22
    public function __construct(string $resource, string $type = null)
23
    {
24
        $this->resource = $resource;
25
        $this->type = $type;
26
        parent::__construct($this->composeMessage($resource, $type));
27
    }
28
29
    public function getResource() : string
30
    {
31
        return $this->resource;
32
    }
33
34
    public function getType() : string
35
    {
36
        return $this->type;
37
    }
38
39
    private function composeMessage(string $resource, string $type = null) : string
40
    {
41
        $message = "Loader not found for the resource: \"{$resource}\"";
42
43
        if (empty($type) == false) {
0 ignored issues
show
Coding Style Best Practice introduced by
It seems like you are loosely comparing two booleans. Considering using the strict comparison === instead.

When comparing two booleans, it is generally considered safer to use the strict comparison operator.

Loading history...
44
            $message .= " and type: \"{$type}\"";
45
        }
46
47
        return $message.'.';
48
    }
49
}
50