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 ( 5e2e05...a169b4 )
by Shcherbak
03:10
created

ElementFinderFactory::create()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 13
Code Lines 9

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 8
CRAP Score 2.032

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 13
ccs 8
cts 10
cp 0.8
rs 9.4285
cc 2
eloc 9
nc 2
nop 2
crap 2.032
1
<?php
2
3
  namespace Xparse\Parser;
4
5
  use GuzzleHttp\Psr7\Response;
6
  use Xparse\ElementFinder\ElementFinder;
7
  use Xparse\ElementFinder\Helper;
8
  use Xparse\Parser\Helper\HtmlEncodingConverter;
9
  use Xparse\Parser\Helper\LinkConverter;
10
11
  /**
12
   * Create ElementFinder.
13
   * Convert charset to UTF-8
14
   * Convert relative links to absolute
15
   * @package Xparse\Parser\Helper
16
   */
17
  class ElementFinderFactory implements ElementFinderFactoryInterface {
18
19
    /**
20
     * @param Response $response
21
     * @param string $affectedUrl
22
     * @return ElementFinder
23
     */
24 13
    public function create(Response $response, $affectedUrl = '') {
25 13
      $html = $response->getBody();
26 13
      $html = Helper::safeEncodeStr((string) $html);
27 13
      $contentType = $response->getHeaderLine('content-type');
28 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...
29 13
      $page = new ElementFinder((string) $html);
30
31 13
      if ($affectedUrl) {
32
        LinkConverter::convertUrlsToAbsolute($page, $affectedUrl);
33
      }
34
35 13
      return $page;
36
    }
37
38
  }