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

Helpers   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 44
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 6
c 1
b 0
f 0
lcom 0
cbo 0
dl 0
loc 44
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A configureAPIURL() 0 9 3
A getSDKVersion() 0 3 1
A getSDKEntryPointRegistry() 0 9 2
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
}