Completed
Pull Request — master (#245)
by Tobias
17:36 queued 07:28
created

Pagination   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 25
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Importance

Changes 0
Metric Value
wmc 2
lcom 0
cbo 1
dl 0
loc 25
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
/*
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