Scrutinizer GitHub App not installed

We could not synchronize checks via GitHub's checks API since Scrutinizer's GitHub App is not installed for this repository.

Install GitHub App

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.

File_Operations::get_http_response_code()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 15
Code Lines 9

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 9
c 1
b 0
f 0
dl 0
loc 15
rs 9.9666
cc 1
nc 1
nop 1
1
<?php
2
/**
3
 *  This file is part of PHP-Typography.
4
 *
5
 *  Copyright 2017-2019 Peter Putzer.
6
 *
7
 *  This program is free software; you can redistribute it and/or modify
8
 *  it under the terms of the GNU General Public License as published by
9
 *  the Free Software Foundation; either version 2 of the License, or
10
 *  (at your option) any later version.
11
 *
12
 *  This program is distributed in the hope that it will be useful,
13
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
14
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15
 *  GNU General Public License for more details.
16
 *
17
 *  You should have received a copy of the GNU General Public License along
18
 *  with this program; if not, write to the Free Software Foundation, Inc.,
19
 *  51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
20
 *
21
 *  ***
22
 *
23
 *  @package mundschenk-at/php-typography
24
 *  @author Peter Putzer <[email protected]>
25
 *  @license http://www.gnu.org/licenses/gpl-2.0.html
26
 */
27
28
namespace PHP_Typography\Bin;
29
30
/**
31
 * Encapsulate some common file operations (including on remote files).
32
 *
33
 * @author Peter Putzer <[email protected]>
34
 *
35
 * @since 5.0.0
36
 */
37
abstract class File_Operations {
38
39
	/**
40
	 * Retrieve a HTTP response code via cURL.
41
	 *
42
	 * @param  string $url Required.
43
	 *
44
	 * @return int
45
	 */
46
	public static function get_http_response_code( $url ) {
47
48
		$curl = curl_init();
49
		curl_setopt_array(
50
			$curl,
0 ignored issues
show
Bug introduced by
It seems like $curl can also be of type false; however, parameter $ch of curl_setopt_array() does only seem to accept resource, maybe add an additional type check? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

50
			/** @scrutinizer ignore-type */ $curl,
Loading history...
51
			[
52
				CURLOPT_RETURNTRANSFER => true,
53
				CURLOPT_URL            => $url,
54
			]
55
		);
56
		curl_exec( $curl );
0 ignored issues
show
Bug introduced by
It seems like $curl can also be of type false; however, parameter $ch of curl_exec() does only seem to accept resource, maybe add an additional type check? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

56
		curl_exec( /** @scrutinizer ignore-type */ $curl );
Loading history...
57
		$response_code = curl_getinfo( $curl, CURLINFO_HTTP_CODE );
0 ignored issues
show
Bug introduced by
It seems like $curl can also be of type false; however, parameter $ch of curl_getinfo() does only seem to accept resource, maybe add an additional type check? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

57
		$response_code = curl_getinfo( /** @scrutinizer ignore-type */ $curl, CURLINFO_HTTP_CODE );
Loading history...
58
		curl_close( $curl );
0 ignored issues
show
Bug introduced by
It seems like $curl can also be of type false; however, parameter $ch of curl_close() does only seem to accept resource, maybe add an additional type check? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

58
		curl_close( /** @scrutinizer ignore-type */ $curl );
Loading history...
59
60
		return $response_code;
61
	}
62
}
63