Joomla Platform  13.1
Documentation des API du framework Joomla Platform
 Tout Classes Espaces de nommage Fichiers Fonctions Variables Pages
meta.php
Aller à la documentation de ce fichier.
1 <?php
2 /**
3  * @package Joomla.Platform
4  * @subpackage GitHub
5  *
6  * @copyright Copyright (C) 2005 - 2013 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  * @package Joomla.Platform
16  * @subpackage GitHub
17  * @since 13.1
18  */
20 {
21  /**
22  * Method to get the authorized IP addresses for services
23  *
24  * @return array Authorized IP addresses
25  *
26  * @since 13.1
27  * @throws DomainException
28  */
29  public function getMeta()
30  {
31  // Build the request path.
32  $path = '/meta';
33 
34  $githubIps = $this->processResponse($this->client->get($this->fetchUrl($path)), 200);
35 
36  /*
37  * The response body returns the IP addresses in CIDR format
38  * Decode the response body and strip the subnet mask information prior to
39  * returning the data to the user. We're assuming quite a bit here that all
40  * masks will be /32 as they are as of the time of development.
41  */
42 
43  $authorizedIps = array();
44 
45  foreach ($githubIps as $key => $serviceIps)
46  {
47  // The first level contains an array of IPs based on the service
48  $authorizedIps[$key] = array();
49 
50  foreach ($serviceIps as $serviceIp)
51  {
52  // The second level is each individual IP address, strip the mask here
53  $authorizedIps[$key][] = substr($serviceIp, 0, -3);
54  }
55  }
56 
57  return $authorizedIps;
58  }
59 }