ChannelIncorrectlyConfigured::getName()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 0
dl 0
loc 3
ccs 2
cts 2
cp 1
crap 1
rs 10
c 0
b 0
f 0
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Yiisoft\Queue\Exception\AdapterConfiguration;
6
7
use InvalidArgumentException;
8
use Throwable;
9
use Yiisoft\FriendlyException\FriendlyExceptionInterface;
10
use Yiisoft\Queue\Adapter\AdapterInterface;
11
use Yiisoft\Queue\QueueFactory;
12
13
class ChannelIncorrectlyConfigured extends InvalidArgumentException implements FriendlyExceptionInterface
14
{
15
    private string $channel;
16
17
    /**
18
     * ChannelIncorrectlyConfigured constructor.
19
     *
20
     * @param mixed|object $definition
21
     * @param Throwable|null $previous
22
     */
23 1
    public function __construct(string $channel, $definition, int $code = 0, ?Throwable $previous = null)
24
    {
25 1
        $adapterClass = AdapterInterface::class;
26 1
        $realType = get_debug_type($definition);
27 1
        $message = "Channel \"$channel\" is not properly configured: definition must return $adapterClass, $realType returned";
28
29 1
        $this->channel = $channel;
30 1
        parent::__construct($message, $code, $previous);
31
    }
32
33 1
    public function getName(): string
34
    {
35 1
        return 'Incorrect queue channel configuration';
36
    }
37
38 1
    public function getSolution(): ?string
39
    {
40 1
        $factoryClass = QueueFactory::class;
41
42 1
        return <<<SOLUTION
43 1
            You tried to get a Queue object for channel "$this->channel" which is incorrectly configured.
44 1
            Please take a look to the documentation for the $factoryClass "\$definitions" constructor parameter.
45 1
            SOLUTION;
46
    }
47
}
48