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 ( 4a2eaa...5e2e05 )
by Shcherbak
7s
created

ElementFinderFactory::getSupportedEncodings()   B

Complexity

Conditions 5
Paths 4

Size

Total Lines 17
Code Lines 10

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 11
CRAP Score 5

Importance

Changes 1
Bugs 0 Features 1
Metric Value
c 1
b 0
f 1
dl 0
loc 17
ccs 11
cts 11
cp 1
rs 8.8571
cc 5
eloc 10
nc 4
nop 0
crap 5
1
<?php
2
3
  namespace Xparse\Parser\Helper;
4
5
  use GuzzleHttp\Psr7\Response;
6
  use Xparse\ElementFinder\ElementFinder;
7
  use Xparse\ElementFinder\Helper;
8
9
  /**
10
   * Create ElementFinder.
11
   * Convert charset to UTF-8
12
   * Convert relative links to absolute
13
   * @package Xparse\Parser\Helper
14
   */
15
  class ElementFinderFactory implements ElementFinderFactoryInterface {
16
17
    /**
18
     * @param Response $response
19
     * @param string $affectedUrl
20
     * @return ElementFinder
21
     */
22 13
    public function create(Response $response, $affectedUrl = '') {
23 13
      $html = $response->getBody();
24 13
      $html = Helper::safeEncodeStr((string) $html);
25 13
      $contentType = $response->getHeaderLine('content-type');
26 13
      $html = HtmlEncodingConverter::convertToUtf($html, $contentType);
0 ignored issues
show
Documentation introduced by
$contentType is of type string, but the function expects a boolean.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
27 13
      $page = new ElementFinder((string) $html);
28
29 13
      if ($affectedUrl) {
30
        LinkConverter::convertUrlsToAbsolute($page, $affectedUrl);
31
      }
32
33 13
      return $page;
34
    }
35
36
  }