AdapterNotConfiguredException::getSolution()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 15
Code Lines 13

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 8
CRAP Score 1

Importance

Changes 0
Metric Value
cc 1
eloc 13
nc 1
nop 0
dl 0
loc 15
ccs 8
cts 8
cp 1
crap 1
rs 9.8333
c 0
b 0
f 0
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Yiisoft\Queue\Exception\AdapterConfiguration;
6
7
use RuntimeException;
8
use Yiisoft\FriendlyException\FriendlyExceptionInterface;
9
use Yiisoft\Queue\Queue;
10
use Yiisoft\Queue\QueueFactory;
11
12
class AdapterNotConfiguredException extends RuntimeException implements FriendlyExceptionInterface
13
{
14
    protected $message = 'Queue adapter is not configured';
15
16 2
    public function getName(): string
17
    {
18 2
        return 'Adapter is not configured';
19
    }
20
21 2
    public function getSolution(): ?string
22
    {
23 2
        $queueClass = Queue::class;
24 2
        $factoryClass = QueueFactory::class;
25
26 2
        return <<<SOLUTION
27 2
            Adapter property must be set in the Queue object before you can use it.
28
            Please use either a constructor "\$adapter" parameter, or "withAdapter()" queue method
29
            to set an appropriate adapter.
30
            A more convenient way to get a configured Queue is a QueueFactory usage.
31
32
            References:
33 2
            - $queueClass::\$adapter
34 2
            - $queueClass::withAdapter()
35 2
            - $factoryClass::get()
36 2
            SOLUTION;
37
    }
38
}
39