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 ( b5e3c2...7799bc )
by
unknown
15s
created

Trees::get()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 9
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 4
nc 1
nop 3
dl 0
loc 9
rs 9.6666
c 0
b 0
f 0
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\Data;
10
11
use Joomla\Github\AbstractPackage;
12
13
/**
14
 * GitHub API Data Trees class for the Joomla Framework.
15
 *
16
 * @documentation http://developer.github.com/v3/git/trees/
17
 *
18
 * @since  1.0
19
 */
20
class Trees extends AbstractPackage
21
{
22
	/**
23
	 * Get a Tree
24
	 *
25
	 * @param   string  $owner  The name of the owner of the GitHub repository.
26
	 * @param   string  $repo   The name of the GitHub repository.
27
	 * @param   string  $sha    The SHA1 value to set the reference to.
28
	 *
29
	 * @since   1.0
30
	 *
31
	 * @return object
32
	 */
33
	public function get($owner, $repo, $sha)
34
	{
35
		// Build the request path.
36
		$path = '/repos/' . $owner . '/' . $repo . '/git/trees/' . $sha;
37
38
		return $this->processResponse(
39
			$this->client->get($this->fetchUrl($path))
40
		);
41
	}
42
43
	/**
44
	 * Get a Tree Recursively
45
	 *
46
	 * @param   string  $owner  The name of the owner of the GitHub repository.
47
	 * @param   string  $repo   The name of the GitHub repository.
48
	 * @param   string  $sha    The SHA1 value to set the reference to.
49
	 *
50
	 * @since   1.0
51
	 *
52
	 * @return object
53
	 */
54
	public function getRecursively($owner, $repo, $sha)
55
	{
56
		// Build the request path.
57
		$path = '/repos/' . $owner . '/' . $repo . '/git/trees/' . $sha . '?recursive=1';
58
59
		return $this->processResponse(
60
			$this->client->get($this->fetchUrl($path))
61
		);
62
	}
63
64
	/**
65
	 * Create a Tree.
66
	 *
67
	 * The tree creation API will take nested entries as well. If both a tree and a nested path
68
	 * modifying that tree are specified, it will overwrite the contents of that tree with the
69
	 * new path contents and write a new tree out.
70
	 *
71
	 * Parameters fir the tree:
72
	 *
73
	 * tree.path
74
	 *     String of the file referenced in the tree
75
	 * tree.mode
76
	 *     String of the file mode - one of 100644 for file (blob), 100755 for executable (blob),
77
	 *     040000 for subdirectory (tree), 160000 for submodule (commit) or 120000 for a blob
78
	 *     that specifies the path of a symlink
79
	 * tree.type
80
	 *     String of blob, tree, commit
81
	 * tree.sha
82
	 *     String of SHA1 checksum ID of the object in the tree
83
	 * tree.content
84
	 *     String of content you want this file to have - GitHub will write this blob out and use
85
	 *     that SHA for this entry. Use either this or tree.sha
86
	 *
87
	 * @param   string  $owner      The name of the owner of the GitHub repository.
88
	 * @param   string  $repo       The name of the GitHub repository.
89
	 * @param   array   $tree       Array of Hash objects (of path, mode, type and sha) specifying
90
	 *                              a tree structure
91
	 * @param   string  $base_tree  The SHA1 of the tree you want to update with new data.
92
	 *
93
	 * @since   1.0
94
	 *
95
	 * @return object
96
	 */
97 View Code Duplication
	public function create($owner, $repo, $tree, $base_tree = '')
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
98
	{
99
		// Build the request path.
100
		$path = '/repos/' . $owner . '/' . $repo . '/git/trees';
101
102
		$data = array();
103
104
		$data['tree'] = $tree;
105
106
		if ($base_tree)
107
		{
108
			$data['base_tree'] = $base_tree;
109
		}
110
111
		return $this->processResponse(
112
			$this->client->post($this->fetchUrl($path), json_encode($data)),
113
			201
114
		);
115
	}
116
}
117