Passed
Push — master ( 2d71d3...7ef273 )
by Dmitriy
04:39 queued 01:43
created

PackageNotInstalledException::getSolution()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 7
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 6
c 1
b 0
f 0
dl 0
loc 7
ccs 0
cts 5
cp 0
rs 10
cc 1
nc 1
nop 0
crap 2
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Yiisoft\Yii\Debug\Api\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