Passed
Pull Request — master (#116)
by Zing
09:46 queued 04:37
created

Paginator   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 38
Duplicated Lines 0 %

Test Coverage

Coverage 76.92%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 10
dl 0
loc 38
ccs 10
cts 13
cp 0.7692
rs 10
c 1
b 0
f 0
wmc 6

5 Methods

Rating   Name   Duplication   Size   Complexity  
A name() 0 3 1
A default() 0 5 1
A getDefault() 0 3 1
A getName() 0 3 1
A __construct() 0 4 2
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Zing\QueryBuilder;
6
7
use function config;
8
9
class Paginator
10
{
11
    /**
12
     * @var string
13
     */
14
    private $name;
15
16
    /**
17
     * @var int
18
     */
19
    private $default;
20
21 2
    public function __construct(string $name, ?int $default = null)
22
    {
23 2
        $this->name = $name;
24 2
        $this->default = $default ?: (int) config('query-builder.per_page.value');
25 2
    }
26
27 2
    public static function name(string $name, ?int $default = null): self
28
    {
29 2
        return new self($name, $default);
30
    }
31
32
    public function default(int $default): self
33
    {
34
        $this->default = $default;
35
36
        return $this;
37
    }
38
39 2
    public function getName(): string
40
    {
41 2
        return $this->name;
42
    }
43
44 2
    public function getDefault(): int
45
    {
46 2
        return $this->default;
47
    }
48
}
49