Serializer   A
last analyzed

Complexity

Total Complexity 1

Size/Duplication

Total Lines 17
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

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

1 Method

Rating   Name   Duplication   Size   Complexity  
A serializePagination() 0 9 1
1
<?php
2
namespace App\Http\Rest;
3
4
use RazonYang\Yii2\JSend\Serializer as BaseSerializer;
5
use Yii;
6
use yii\web\Link;
7
8
class Serializer extends BaseSerializer
9
{
10
    public $collectionEnvelope = 'items';
11
12
    public $linksEnvelope = 'links';
13
14
    public $metaEnvelope = 'meta';
15
16
    protected function serializePagination($pagination)
17
    {
18
        return [
19
            $this->linksEnvelope => Link::serialize($pagination->getLinks(true)),
20
            $this->metaEnvelope => [
21
                'limit' => $pagination->getPageSize(),
22
                'page' => $pagination->getPage() + 1,
23
                'page_count' => $pagination->getPageCount(),
24
                'total_count' => $pagination->totalCount,
25
            ],
26
        ];
27
    }
28
}
29