1 <?php
2 /**
3 * @package Joomla.Platform
4 * @subpackage GitHub
5 *
6 * @copyright Copyright (C) 2005 - 2017 Open Source Matters, Inc. All rights reserved.
7 * @license GNU General Public License version 2 or later; see LICENSE
8 */
9
10 defined('JPATH_PLATFORM') or die;
11
12 /**
13 * GitHub API Meta class.
14 *
15 * @since 13.1
16 * @deprecated 4.0 Use the `joomla/github` package via Composer instead
17 */
18 class JGithubMeta extends JGithubObject
19 {
20 /**
21 * Method to get the authorized IP addresses for services
22 *
23 * @return array Authorized IP addresses
24 *
25 * @since 13.1
26 * @throws DomainException
27 */
28 public function getMeta()
29 {
30 // Build the request path.
31 $path = '/meta';
32
33 $githubIps = $this->processResponse($this->client->get($this->fetchUrl($path)), 200);
34
35 /*
36 * The response body returns the IP addresses in CIDR format
37 * Decode the response body and strip the subnet mask information prior to
38 * returning the data to the user. We're assuming quite a bit here that all
39 * masks will be /32 as they are as of the time of development.
40 */
41
42 $authorizedIps = array();
43
44 foreach ($githubIps as $key => $serviceIps)
45 {
46 // The first level contains an array of IPs based on the service
47 $authorizedIps[$key] = array();
48
49 foreach ($serviceIps as $serviceIp)
50 {
51 // The second level is each individual IP address, strip the mask here
52 $authorizedIps[$key][] = substr($serviceIp, 0, -3);
53 }
54 }
55
56 return $authorizedIps;
57 }
58 }
59