Completed
Pull Request — master (#245)
by Tobias
07:56
created

Pagination::getPaginationUrl()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 12
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 12
rs 9.4285
c 0
b 0
f 0
cc 2
eloc 6
nc 2
nop 2
1
<?php
2
3
namespace Mailgun\Api;
4
5
use Mailgun\Assert;
6
use Psr\Http\Message\ResponseInterface;
7
8
/**
9
 * @author Tobias Nyholm <[email protected]>
10
 */
11
trait Pagination
12
{
13
    abstract protected function httpGet($path, array $parameters = [], array $requestHeaders = []);
14
    abstract protected function safeDeserialize(ResponseInterface $response, $className);
15
16
    /**
17
     * @param string $url
18
     * @param string $class
19
     *
20
     * @return mixed|null
21
     */
22
    public function getPaginationUrl($url, $class)
23
    {
24
        Assert::stringNotEmpty($class);
25
26
        if (empty($url)) {
27
            return;
28
        }
29
30
        $response = $this->httpGet($url);
31
32
        return $this->safeDeserialize($response, $class);
33
    }
34
}
35