GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.
Completed
Push — master ( 8188fa...e2d4ee )
by Kivanio
03:00
created

LastRequest::getLinks()   A

Complexity

Conditions 3
Paths 3

Size

Total Lines 15
Code Lines 12

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 13
CRAP Score 3

Importance

Changes 0
Metric Value
dl 0
loc 15
ccs 13
cts 13
cp 1
rs 9.4285
c 0
b 0
f 0
cc 3
eloc 12
nc 3
nop 1
crap 3
1
<?php
2
3
namespace BoletoSimples;
4
5
class LastRequest {
6
  /**
7
   * Content of response header Total
8
   */
9
  public $total = null;
10
11
  /**
12
   * Content of response header X-Ratelimit-Limit
13
   */
14
  public $ratelimit_limit = null;
15
16
  /**
17
   * Content of response header X-Ratelimit-Remaining
18
   */
19
  public $ratelimit_remaining = null;
20
21
  /**
22
   * Array with links returned on header Link
23
   */
24
  public $links = null;
25
26
  /**
27
   * GuzzleHttp\Message\Request object
28
   */
29
  public $request = null;
30
31
  /**
32
   * GuzzleHttp\Message\Response object
33
   */
34
  public $response = null;
35
36
  /**
37
   * Constructor method.
38
   */
39 12
  public function __construct($request, $response) {
40 12
    $this->request = $request;
41 12
    $this->response = $response;
42
43 12
    $this->total = $response->getHeader('Total');
44 12
    $this->ratelimit_limit = $response->getHeader('X-Ratelimit-Limit');
45 12
    $this->ratelimit_remaining = $response->getHeader('X-Ratelimit-Remaining');
46 12
    $this->links = $this->getLinks($response);
47 12
  }
48
49 12
  private function getLinks($response) {
50 12
    $link_header = $response->getHeader('Link');
51 12
    if ($link_header == null) {
52 10
      return [];
53
    }
54 2
    $links = [];
55 2
    foreach (explode(', ', $link_header) as $link) {
56 2
      preg_match('/rel=\"(.*)\"/', $link, $matches);
57 2
      $key = $matches[1];
58 2
      preg_match('/\<(.*)\>/', $link, $matches);
59 2
      $value = $matches[1];
60 2
      $links[$key] = $value;
61 2
    }
62 2
    return $links;
63
  }
64
}