Completed
Push — master ( 479df9...de13ff )
by Sean
03:26
created

Pagination::getPaginationUrl()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 12
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 6

Importance

Changes 0
Metric Value
dl 0
loc 12
ccs 0
cts 6
cp 0
rs 9.4285
c 0
b 0
f 0
cc 2
eloc 6
nc 2
nop 2
crap 6
1
<?php
2
3
/*
4
 * Copyright (C) 2013-2016 Mailgun
5
 *
6
 * This software may be modified and distributed under the terms
7
 * of the MIT license. See the LICENSE file for details.
8
 */
9
10
namespace Mailgun\Api;
11
12
use Mailgun\Assert;
13
use Psr\Http\Message\ResponseInterface;
14
15
/**
16
 * @author Tobias Nyholm <[email protected]>
17
 */
18
trait Pagination
19
{
20
    abstract protected function httpGet($path, array $parameters = [], array $requestHeaders = []);
21
22
    abstract protected function safeDeserialize(ResponseInterface $response, $className);
23
24
    /**
25
     * @param string $url
26
     * @param string $class
27
     *
28
     * @return mixed|null
29
     */
30
    public function getPaginationUrl($url, $class)
31
    {
32
        Assert::stringNotEmpty($class);
33
34
        if (empty($url)) {
35
            return;
36
        }
37
38
        $response = $this->httpGet($url);
39
40
        return $this->safeDeserialize($response, $class);
41
    }
42
}
43