Completed
Push — master ( 396778...5e0c6d )
by Changwan
03:27
created

RequirePackageException   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 39
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
dl 0
loc 39
ccs 0
cts 18
cp 0
rs 10
c 0
b 0
f 0
wmc 4
lcom 0
cbo 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 10 2
A getClass() 0 4 1
A getPackage() 0 4 1
1
<?php
2
namespace Wandu\DI\Exception;
3
4
use Interop\Container\Exception\NotFoundException;
5
use Psr\Container\NotFoundExceptionInterface;
6
use RuntimeException;
7
8
class RequirePackageException extends RuntimeException implements NotFoundExceptionInterface, NotFoundException
9
{
10
    /** @var string */
11
    protected $class;
12
13
    /** @var string */
14
    protected $package;
15
16
    /**
17
     * @param string $class
18
     * @param string $package
19
     */
20
    public function __construct($class, $package)
21
    {
22
        $traces = debug_backtrace();
23
        $this->message = "cannot find the \"{$class}\" class, install \"{$package}\" package.";
24
        $this->package = $package;
25
        if (isset($traces[1])) {
26
            $this->file = $traces[1]['file'];
27
            $this->line = $traces[1]['line'];
28
        }
29
    }
30
31
    /**
32
     * @return string
33
     */
34
    public function getClass()
35
    {
36
        return $this->class;
37
    }
38
39
    /**
40
     * @return string
41
     */
42
    public function getPackage()
43
    {
44
        return $this->package;
45
    }
46
}
47