Completed
Push — master ( c7c88d...7873ee )
by Mike
02:24
created

Helpers::configureAPIURL()   A

Complexity

Conditions 3
Paths 4

Size

Total Lines 9
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 9
rs 9.6666
cc 3
eloc 6
nc 4
nop 1
1
<?php
2
3
namespace SugarAPI\SDK\Helpers;
4
5
6
class Helpers {
7
8
    const API_URL = '/rest/v10/';
9
10
    const SDK_VERSION = '1.0';
11
12
    /**
13
     * Given a sugarcrm server/instance generate the Rest/v10 API Url
14
     * @param $instance
15
     * @return string
16
     */
17
    public static function configureAPIURL($instance){
18
        if (strpos("http", $instance)===FALSE){
19
            $instance = "http://".$instance;
20
        }
21
        if (strpos("rest/v10", $instance)!==FALSE){
22
            $instance = str_replace("rest/v10", "", $instance);
23
        }
24
        return rtrim($instance, "/").self::API_URL;
25
    }
26
27
    /**
28
     * Return the current SDK Version
29
     * @return string
30
     */
31
    public static function getSDKVersion(){
32
        return self::SDK_VERSION;
33
    }
34
35
    /**
36
     * Return the list of EntryPoints that come with the SDK
37
     * @return array
38
     */
39
    public static function getSDKEntryPointRegistry(){
40
        $entryPoints = array();
41
        require __DIR__.DIRECTORY_SEPARATOR.'registry.php';
42
        foreach ($entryPoints as $funcName => $className) {
43
            $className = "SugarAPI\\SDK\\EntryPoint\\" . $className;
44
            $entryPoints[$funcName] = $className;
45
        }
46
        return $entryPoints;
47
    }
48
49
}