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 ( 71704d...4e2ecb )
by Kivanio
06:24
created

LastRequest::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 9
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 8
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 1
Metric Value
c 1
b 0
f 1
dl 0
loc 9
ccs 8
cts 8
cp 1
rs 9.6666
cc 1
eloc 7
nc 1
nop 2
crap 1
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
}