HasResponsePagination::from()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 1
c 1
b 0
f 0
nc 1
nop 0
dl 0
loc 3
ccs 2
cts 2
cp 1
crap 1
rs 10
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