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

Pagination   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 24
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Importance

Changes 0
Metric Value
wmc 2
lcom 0
cbo 1
dl 0
loc 24
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
httpGet() 0 1 ?
safeDeserialize() 0 1 ?
A getPaginationUrl() 0 12 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