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 — develop ( 06e328...3bdb15 )
by
unknown
14s
created

github/src/Package/Repositories/Downloads.php (3 issues)

Upgrade to new PHP Analysis Engine

These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more

1
<?php
2
/**
3
 * Part of the Joomla Framework GitHub Package
4
 *
5
 * @copyright  Copyright (C) 2005 - 2015 Open Source Matters, Inc. All rights reserved.
6
 * @license    GNU General Public License version 2 or later; see LICENSE
7
 */
8
9
namespace Joomla\Github\Package\Repositories;
10
11
use Joomla\Github\AbstractPackage;
12
13
/**
14
 * GitHub API Repositories Downloads class for the Joomla Framework.
15
 *
16
 * The downloads API is for package downloads only.
17
 * If you want to get source tarballs you should use
18
 * http://developer.github.com/v3/repos/contents/#get-archive-link instead.
19
 *
20
 * @documentation  https://developer.github.com/v3/repos/downloads
21
 *
22
 * @since       1.0
23
 * @deprecated  The Releases API should be used instead
24
 */
25
class Downloads extends AbstractPackage
26
{
27
	/**
28
	 * List downloads for a repository.
29
	 *
30
	 * @param   string  $owner  The name of the owner of the GitHub repository.
31
	 * @param   string  $repo   The name of the GitHub repository.
32
	 *
33
	 * @return  object
34
	 *
35
	 * @since   1.0
36
	 * @deprecated  The Releases API should be used instead
37
	 */
38
	public function getList($owner, $repo)
39
	{
40
		// Build the request path.
41
		$path = '/repos/' . $owner . '/' . $repo . '/downloads';
42
43
		// Send the request.
44
		return $this->processResponse(
45
			$this->client->get($this->fetchUrl($path))
46
		);
47
	}
48
49
	/**
50
	 * Get a single download.
51
	 *
52
	 * @param   string   $owner  The name of the owner of the GitHub repository.
53
	 * @param   string   $repo   The name of the GitHub repository.
54
	 * @param   integer  $id     The id of the download.
55
	 *
56
	 * @return  object
57
	 *
58
	 * @since   1.0
59
	 * @deprecated  The Releases API should be used instead
60
	 */
61
	public function get($owner, $repo, $id)
62
	{
63
		// Build the request path.
64
		$path = '/repos/' . $owner . '/' . $repo . '/downloads/' . $id;
65
66
		// Send the request.
67
		return $this->processResponse(
68
			$this->client->get($this->fetchUrl($path))
69
		);
70
	}
71
72
	/**
73
	 * Create a new download (Part 1: Create the resource).
74
	 *
75
	 * Creating a new download is a two step process. You must first create a new download resource.
76
	 *
77
	 * @param   string  $owner         The name of the owner of the GitHub repository.
78
	 * @param   string  $repo          The name of the GitHub repository.
79
	 * @param   string  $name          The name.
80
	 * @param   string  $size          Size of file in bytes.
81
	 * @param   string  $description   The description.
82
	 * @param   string  $content_type  The content type.
83
	 *
84
	 * @return  boolean
85
	 *
86
	 * @note    This API endpoint no longer exists at GitHub
87
	 * @since   1.0
88
	 * @throws  \RuntimeException
89
	 * @deprecated  The Releases API should be used instead
90
	 */
91
	public function create($owner, $repo, $name, $size, $description = '', $content_type = '')
0 ignored issues
show
The parameter $content_type is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
92
	{
93
		throw new \RuntimeException('The GitHub API no longer supports creating downloads. The Releases API should be used instead.');
94
	}
95
96
	/**
97
	 * Create a new download (Part 2: Upload file to s3).
98
	 *
99
	 * Now that you have created the download resource, you can use the information
100
	 * in the response to upload your file to s3. This can be done with a POST to
101
	 * the s3_url you got in the create response. Here is a brief example using curl:
102
	 *
103
	 * curl \
104
	 *     -F "key=downloads/octocat/Hello-World/new_file.jpg" \
105
	 *     -F "acl=public-read" \
106
	 *     -F "success_action_status=201" \
107
	 *     -F "Filename=new_file.jpg" \
108
	 *     -F "AWSAccessKeyId=1ABCDEF..." \
109
	 *     -F "Policy=ewogIC..." \
110
	 *     -F "Signature=mwnF..." \
111
	 *     -F "Content-Type=image/jpeg" \
112
	 *     -F "file=@new_file.jpg" \
113
	 *           https://github.s3.amazonaws.com/
114
	 *
115
	 * NOTES
116
	 * The order in which you pass these fields matters! Follow the order shown above exactly.
117
	 * All parameters shown are required and if you excluded or modify them your upload will
118
	 * fail because the values are hashed and signed by the policy.
119
	 *
120
	 * More information about using the REST API to interact with s3 can be found here:
121
	 * http://docs.amazonwebservices.com/AmazonS3/latest/API/
122
	 *
123
	 * @param   string  $key                    Value of path field in the response.
124
	 * @param   string  $acl                    Value of acl field in the response.
125
	 * @param   string  $success_action_status  201, or whatever you want to get back.
126
	 * @param   string  $filename               Value of name field in the response.
127
	 * @param   string  $awsAccessKeyId         Value of accesskeyid field in the response.
128
	 * @param   string  $policy                 Value of policy field in the response.
129
	 * @param   string  $signature              Value of signature field in the response.
130
	 * @param   string  $content_type           Value of mime_type field in the response.
131
	 * @param   string  $file                   Local file. Example assumes the file existing in the directory
132
	 *                                          where you are running the curl command. Yes, the @ matters.
133
	 *
134
	 * @return  boolean
135
	 *
136
	 * @note    This API endpoint no longer exists at GitHub
137
	 * @since   1.0
138
	 * @throws  \RuntimeException
139
	 * @deprecated  The Releases API should be used instead
140
	 */
141
	public function upload($key, $acl, $success_action_status, $filename, $awsAccessKeyId, $policy, $signature, $content_type, $file)
0 ignored issues
show
The parameter $success_action_status is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
The parameter $content_type is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
142
	{
143
		throw new \RuntimeException('The GitHub API no longer supports creating downloads. The Releases API should be used instead.');
144
	}
145
146
	/**
147
	 * Delete a download.
148
	 *
149
	 * @param   string   $owner  The name of the owner of the GitHub repository.
150
	 * @param   string   $repo   The name of the GitHub repository.
151
	 * @param   integer  $id     The id of the download.
152
	 *
153
	 * @return  object
154
	 *
155
	 * @since   1.0
156
	 * @deprecated  The Releases API should be used instead
157
	 */
158 View Code Duplication
	public function delete($owner, $repo, $id)
159
	{
160
		// Build the request path.
161
		$path = '/repos/' . $owner . '/' . $repo . '/downloads/' . (int) $id;
162
163
		// Send the request.
164
		return $this->processResponse(
165
			$this->client->delete($this->fetchUrl($path)),
166
			204
167
		);
168
	}
169
}
170