HasResponsePagination   A
last analyzed

Complexity

Total Complexity 7

Size/Duplication

Total Lines 37
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 8
c 1
b 0
f 0
dl 0
loc 37
ccs 14
cts 14
cp 1
rs 10
wmc 7

7 Methods

Rating   Name   Duplication   Size   Complexity  
A perPage() 0 3 1
A items() 0 3 1
A to() 0 3 1
A currentPage() 0 3 1
A total() 0 3 1
A from() 0 3 1
A lastPage() 0 3 1
1
<?php
2
3
namespace Reviewsio\Endpoints;
4
5
trait HasResponsePagination
6
{
7
    abstract protected function entityKey(): string;
8
9 1
    public function total(): int
10
    {
11 1
        return (int) $this->baseResponse()->json("{$this->entityKey()}.total", 0);
0 ignored issues
show
Bug introduced by
It seems like baseResponse() must be provided by classes using this trait. How about adding it as abstract method to this trait? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

11
        return (int) $this->/** @scrutinizer ignore-call */ baseResponse()->json("{$this->entityKey()}.total", 0);
Loading history...
12
    }
13
14 1
    public function perPage(): int
15
    {
16 1
        return (int) $this->baseResponse()->json("{$this->entityKey()}.per_page", 0);
17
    }
18
19 1
    public function currentPage(): int
20
    {
21 1
        return (int) $this->baseResponse()->json("{$this->entityKey()}.current_page", 0);
22
    }
23
24 1
    public function lastPage(): int
25
    {
26 1
        return (int) $this->baseResponse()->json("{$this->entityKey()}.last_page", 0);
27
    }
28
29 1
    public function from(): int
30
    {
31 1
        return (int) $this->baseResponse()->json("{$this->entityKey()}.from", 0);
32
    }
33
34 1
    public function to(): int
35
    {
36 1
        return (int) $this->baseResponse()->json("{$this->entityKey()}.to", 0);
37
    }
38
39 1
    public function items(): array
40
    {
41 1
        return $this->baseResponse()->json("{$this->entityKey()}.data", []);
42
    }
43
}
44