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.

LastRequest::getLinks()   A
last analyzed

Complexity

Conditions 3
Paths 3

Size

Total Lines 15

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 12
CRAP Score 3.004

Importance

Changes 0
Metric Value
dl 0
loc 15
ccs 12
cts 13
cp 0.9231
rs 9.7666
c 0
b 0
f 0
cc 3
nc 3
nop 1
crap 3.004
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 1
  public function __construct($request, $response) {
40 1
    $this->request = $request;
41 1
    $this->response = $response;
42
43 1
    $this->total = $response->getHeader('Total');
44 1
    $this->ratelimit_limit = $response->getHeader('X-Ratelimit-Limit');
45 1
    $this->ratelimit_remaining = $response->getHeader('X-Ratelimit-Remaining');
46 1
    $this->links = $this->getLinks($response);
47 1
  }
48
49 1
  private function getLinks($response) {
50 1
    $link_header = $response->getHeader('Link');
51 1
    if ($link_header == null) {
52
      return [];
53
    }
54 1
    $links = [];
55 1
    foreach (explode(', ', $link_header) as $link) {
56 1
      preg_match('/rel=\"(.*)\"/', $link, $matches);
57 1
      $key = $matches[1];
58 1
      preg_match('/\<(.*)\>/', $link, $matches);
59 1
      $value = $matches[1];
60 1
      $links[$key] = $value;
61 1
    }
62 1
    return $links;
63
  }
64
}