Meta   A
last analyzed

Complexity

Total Complexity 9

Size/Duplication

Total Lines 74
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 1
Metric Value
eloc 11
c 1
b 0
f 1
dl 0
loc 74
ccs 18
cts 18
cp 1
rs 10
wmc 9

9 Methods

Rating   Name   Duplication   Size   Complexity  
A hasNext() 0 3 1
A next() 0 3 1
A __construct() 0 3 1
A page() 0 3 1
A limit() 0 3 1
A hasPrev() 0 3 1
A total() 0 3 1
A pages() 0 3 1
A prev() 0 3 1
1
<?php
2
3
namespace Igorsgm\Ghost\Models;
4
5
class Meta extends BaseModel
6
{
7
    /**
8
     * @var array
9
     */
10
    public $pagination;
11
12 53
    public function __construct(array $data = [])
13
    {
14 53
        $this->pagination = (object) ($data['pagination'] ?? []);
0 ignored issues
show
Documentation Bug introduced by
It seems like (object)$data['pagination'] ?? array() of type object is incompatible with the declared type array of property $pagination.

Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.

Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..

Loading history...
15
    }
16
17
    /**
18
     * @return int
19
     */
20 5
    public function page()
21
    {
22 5
        return $this->pagination->page ?? null;
23
    }
24
25
    /**
26
     * @return int
27
     */
28 5
    public function limit()
29
    {
30 5
        return $this->pagination->limit ?? null;
31
    }
32
33
    /**
34
     * @return int
35
     */
36 5
    public function pages()
37
    {
38 5
        return $this->pagination->pages ?? null;
39
    }
40
41
    /**
42
     * @return int
43
     */
44 5
    public function total()
45
    {
46 5
        return $this->pagination->total ?? null;
47
    }
48
49
    /**
50
     * @return bool
51
     */
52 6
    public function hasNext()
53
    {
54 6
        return ! empty($this->pagination->next);
55
    }
56
57
    /**
58
     * @return int
59
     */
60 6
    public function next()
61
    {
62 6
        return $this->pagination->next ?? null;
63
    }
64
65
    /**
66
     * @return bool
67
     */
68 6
    public function hasPrev()
69
    {
70 6
        return ! empty($this->pagination->prev);
71
    }
72
73
    /**
74
     * @return int
75
     */
76 6
    public function prev()
77
    {
78 6
        return $this->pagination->prev ?? null;
79
    }
80
}
81