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

RequirePackageException::__construct()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 10
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 6

Importance

Changes 0
Metric Value
cc 2
eloc 7
nc 2
nop 2
dl 0
loc 10
ccs 0
cts 10
cp 0
crap 6
rs 9.4285
c 0
b 0
f 0
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