PaginatorNotSetException::__construct()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 2
eloc 2
c 1
b 0
f 0
nc 2
nop 1
dl 0
loc 4
ccs 3
cts 3
cp 1
crap 2
rs 10
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Yiisoft\Yii\DataView\Exception;
6
7
use RuntimeException;
8
use Yiisoft\FriendlyException\FriendlyExceptionInterface;
9
10
final class PaginatorNotSetException extends RuntimeException implements FriendlyExceptionInterface
11
{
12 1
    public function __construct(string $message = '')
13
    {
14 1
        $message = $message === '' ? $this->getName() : $message;
15 1
        parent::__construct($message);
16
    }
17
18 1
    public function getName(): string
19
    {
20 1
        return 'Failed to create widget because "paginator" is not set.';
21
    }
22
23
    public function getSolution(): ?string
24
    {
25
        return <<<SOLUTION
26
            You can configure the `paginator` property in the widget configuration. Use either `OffSetPaginator::class`
27
            or `KeySetPaginator::class` as paginator.
28
            For more information [see the documentation](https://github.com/yiisoft/data).
29
        SOLUTION;
30
    }
31
}
32