ChannelIncorrectlyConfigured   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 32
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
eloc 13
dl 0
loc 32
ccs 13
cts 13
cp 1
rs 10
c 0
b 0
f 0
wmc 3

3 Methods

Rating   Name   Duplication   Size   Complexity  
A getSolution() 0 7 1
A __construct() 0 8 1
A getName() 0 3 1
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