-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathgoogle-api-php-client.php
executable file
·82 lines (73 loc) · 2.41 KB
/
google-api-php-client.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
<?php
/**
* @author Andrew Zappella < http://www.suisseo.ch/ >
* @copyright 2012 Suisseo SARL
* @license http://creativecommons.org/licenses/by-sa/3.0/
* @package Google API PHP Client (Laravel Bundle)
* @version 0.2.1 - 2013-03-17
*/
class Google {
const BUNDLE_NAME = 'google-api-php-client';
/**
* All the service names for Google API
*/
public static $services = array();
/**
* Return the Google API services class files
*
* @return array $services with the format apiAdsenseService.php,
*/
public static function services()
{
// Fetch all Google API services classes from Bundle folder.
// scandir returns the files of a folder including '.' & '..' so we slice
// the returned array to remove them.
$classes = array_slice(scandir(Bundle::path('google-api-php-client')
.'google-api-php-client'.DS.'src'.DS.'contrib'.DS), 2);
return self::$services = $classes;
}
/**
* Return the name of the Google API service
*
* @param string @service e.g. Google_AdsenseService.php
* @return string
*/
public static function service_name($service)
{
return str_replace('Service.php','',str_replace('Google_','',$service));
}
/**
* Return the path of the Google API service class file
*
* @param string $class e.g. Google_AdsenseService.php
* @return string service class path
*/
public static function format_path($class)
{
$path = Bundle::path(BUNDLE_NAME).'google-api-php-client'.DS.'src'.DS.'contrib'.DS;
return $path . $class;
}
/**
* Return the name of the Google API service class name
*
* @param string $class e.g. Google_AdsenseService.php
* @return string service class name
*/
public static function strip_extension($class)
{
return str_replace('.php', '', $class);
}
/**
* Format the Google API services class files to be used by laravel's
* Autoloader::map() method.
*
* @param array $classes e.g. array('Google_AdsenseService.php', 'Google
* @return array mappings for the Autoloader::map() method
*/
public static function format_mappings($classes)
{
$class_names = array_map(array(__CLASS__,'self::strip_extension'), $classes);
$class_paths = array_map(array(__CLASS__,'self::format_path'), $classes);
return array_combine($class_names, $class_paths);
}
}