Passed
Push — master ( 1ffb2d...f18857 )
by Dmitriy
05:56 queued 02:52
created

PackageNotInstalledException   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 26
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
eloc 11
dl 0
loc 26
ccs 0
cts 12
cp 0
rs 10
c 0
b 0
f 0
wmc 3

3 Methods

Rating   Name   Duplication   Size   Complexity  
A getName() 0 5 1
A getSolution() 0 7 1
A __construct() 0 7 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Yiisoft\Yii\Debug\Api\Debug\Exception;
6
7
use Exception;
8
use Throwable;
9
use Yiisoft\FriendlyException\FriendlyExceptionInterface;
10
11
final class PackageNotInstalledException extends Exception implements FriendlyExceptionInterface
12
{
13
    public function __construct(
14
        private string $packageName,
15
        string $message = '',
16
        int $code = 0,
17
        ?Throwable $previous = null
18
    ) {
19
        parent::__construct($message, $code, $previous);
20
    }
21
22
    public function getName(): string
23
    {
24
        return sprintf(
25
            'Package "%s" is not installed.',
26
            $this->packageName,
27
        );
28
    }
29
30
    public function getSolution(): string
31
    {
32
        return <<<MARKDOWN
33
            Probably you forgot to install the package.
34
35
            Run `composer require {$this->packageName}` and configure the package in your application.
36
            Visit [yiisoft/yii-debug-api](https://github.com/{$this->packageName}) for more details.
37
            MARKDOWN;
38
    }
39
}
40