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 ( b3ee5f...a83cd4 )
by Brad
06:08 queued 03:01
created

FooGallery_PixabayClient   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 70
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Importance

Changes 0
Metric Value
dl 0
loc 70
rs 10
c 0
b 0
f 0
wmc 2
lcom 0
cbo 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A search() 0 25 2
1
<?php
2
/**
3
 * pixabay-php-api
4
 * PixabayClient API
5
 *
6
 * PHP Version 5
7
 *
8
 * @category Production
9
 * @package  Default
10
 * @author   Philipp Tkachev <[email protected]>
11
 * @date     12/14/14 9:18 AM
12
 * @license  https://www.zoonman.com/projects/pixabay/license.txt MIT
13
 * @version  GIT: 1.0
14
 * @link     https://www.zoonman.com/projects/pixabay/
15
 */
16
17
/**
18
 * Class FooGallery_PixabayClient
19
 */
20
class FooGallery_PixabayClient {
0 ignored issues
show
Coding Style Compatibility introduced by
PSR1 recommends that each class must be in a namespace of at least one level to avoid collisions.

You can fix this by adding a namespace to your class:

namespace YourVendor;

class YourClass { }

When choosing a vendor namespace, try to pick something that is not too generic to avoid conflicts with other libraries.

Loading history...
21
	/**
22
	 * @var array
23
	 */
24
	private $optionsList = [
25
		'key',
26
		'response_group',
27
		'id',
28
		'q',
29
		'lang',
30
		'callback',
31
		'image_type',
32
		'orientation',
33
		'category',
34
		'min_width',
35
		'min_height',
36
		'editors_choice',
37
		'safesearch',
38
		'page',
39
		'per_page',
40
		'pretty',
41
		'response_group',
42
		'order',
43
		'video_type'
44
	];
45
46
	/**
47
	 * Root of Pixabay REST API
48
	 */
49
	const API_ROOT = 'https://pixabay.com/api/';
50
51
	/**
52
	 * Get Data from Pixabay API
53
	 *
54
	 * @param        $key
55
	 * @param        $query
56
	 * @param int    $count
57
	 * @param string $image_type
58
	 * @param string $response_group
59
	 *
60
	 * @param string $safesearch
61
	 *
62
	 * @return mixed
63
	 */
64
	public function search( $key, $query, $count = 20, $image_type = 'photo', $response_group = 'high_resolution', $safesearch = 'true')
65
	{
66
		$url = add_query_arg( array(
67
			'key' => $key,
68
			'q' => urlencode( $query ),
69
			'per_page' => $count,
70
			'image_type' => $image_type,
71
			'response_group' => $response_group,
72
			'safesearch' => $safesearch
73
		), self::API_ROOT );
74
75
		$transient_key = 'foogallery-pixabay-' . urlencode($query) . '-' . $count;
76
77
		if ( false === ( $response_data = get_transient( $transient_key ) ) ) {
78
			$response = wp_remote_get( $url );
79
			$response_data = wp_remote_retrieve_body( $response );
80
81
			$expires = 60 * 60 * 24; //cache for 24 hours
82
83
			//Cache the result
84
			set_transient( $transient_key, $response_data, $expires );
85
		}
86
87
		return json_decode( $response_data, false );
88
	}
89
}