Helpers::getSDKVersion()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

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