Passed
Push — master ( 196500...6911db )
by Alexander
45:54 queued 24:21
created

ExtractException::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 12

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 6
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 12
ccs 6
cts 6
cp 1
rs 9.8666
c 0
b 0
f 0
cc 1
nc 1
nop 4
crap 1
1
<?php
2
3
namespace Horat1us\Yii\Exceptions\Behavior;
4
5
use Throwable;
6
use yii\base;
7
8
/**
9
 * Class ExtractException
10
 * @package Horat1us\Yii\Exceptions\Behavior
11
 */
12
class ExtractException extends base\InvalidConfigException
13
{
14
    /** @var base\Behavior */
15
    protected $behavior;
16
17
    /** @var string */
18
    protected $targetClass;
19
20 1
    public function __construct(
21
        base\Behavior $behavior,
22
        string $targetClass,
23
        int $code = 0,
24
        Throwable $previous = null
25
    ) {
26 1
        $message = get_class($behavior) . " can be applied only to {$targetClass}";
27 1
        parent::__construct($message, $code, $previous);
28
29 1
        $this->behavior = $behavior;
30 1
        $this->targetClass = $targetClass;
31 1
    }
32
33 1
    public function getBehavior(): base\Behavior
34
    {
35 1
        return $this->behavior;
36
    }
37
38 1
    public function getTargetClass(): string
39
    {
40 1
        return $this->targetClass;
41
    }
42
}
43