Completed
Push — master ( 15515b...fd48c6 )
by Mike
02:14
created
src/Request/Interfaces/RequestInterface.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -23,7 +23,7 @@  discard block
 block discarded – undo
23 23
      * @param $value - Header Value
24 24
      * @return SugarAPI\SDK\Request Object
25 25
      */
26
-    public function addHeader($name,$value);
26
+    public function addHeader($name, $value);
27 27
 
28 28
     /**
29 29
      * Sets the Headers on the Curl Request object, called during Sending. Appends to Request Headers property
@@ -50,7 +50,7 @@  discard block
 block discarded – undo
50 50
      * @param $value - Curl Option Value
51 51
      * @return SugarAPI\SDK\Request Object
52 52
      */
53
-    public function setOption($option,$value);
53
+    public function setOption($option, $value);
54 54
 
55 55
     /**
56 56
      * Set the URL on the Request Object
Please login to merge, or discard this patch.
examples/Login.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -1,7 +1,7 @@
 block discarded – undo
1 1
 <?php
2 2
 
3
-require_once __DIR__ . '/../vendor/autoload.php';
3
+require_once __DIR__.'/../vendor/autoload.php';
4 4
 
5
-$SugarAPI = new \SugarAPI\SDK\SugarAPI('instances.this/Ent/7621/',array('username' => 'admin','password'=>'asdf'));
5
+$SugarAPI = new \SugarAPI\SDK\SugarAPI('instances.this/Ent/7621/', array('username' => 'admin', 'password'=>'asdf'));
6 6
 $SugarAPI->login();
7 7
 print_r($SugarAPI->getToken());
8 8
\ No newline at end of file
Please login to merge, or discard this patch.
src/SugarAPI.php 2 patches
Unused Use Statements   -2 removed lines patch added patch discarded remove patch
@@ -2,8 +2,6 @@
 block discarded – undo
2 2
 
3 3
 namespace SugarAPI\SDK;
4 4
 
5
-use SugarAPI\SDK\Exception\InitializationFailure;
6
-use SugarAPI\SDK\Exception\InvalidEntryPoint;
7 5
 use SugarAPI\SDK\Exception\AuthenticationException;
8 6
 use SugarAPI\SDK\Exception\SDKException;
9 7
 
Please login to merge, or discard this patch.
Spacing   +17 added lines, -17 removed lines patch added patch discarded remove patch
@@ -28,7 +28,7 @@  discard block
 block discarded – undo
28 28
 
29 29
     private $entryPoints = array();
30 30
 
31
-    public function __construct($instance='',array $authOptions = array()){
31
+    public function __construct($instance = '', array $authOptions = array()){
32 32
         $this->loadDefaults();
33 33
         if (!empty($instance)){
34 34
             $this->setInstance($instance);
@@ -40,8 +40,8 @@  discard block
 block discarded – undo
40 40
     }
41 41
 
42 42
     protected function loadDefaults(){
43
-        include __DIR__ .DIRECTORY_SEPARATOR.'defaults.php';
44
-        if (isset($defaults)) {
43
+        include __DIR__.DIRECTORY_SEPARATOR.'defaults.php';
44
+        if (isset($defaults)){
45 45
             static::$_DEFAULTS = $defaults;
46 46
             if (isset($defaults['instance'])){
47 47
                 $this->setInstance($defaults['instance']);
@@ -53,7 +53,7 @@  discard block
 block discarded – undo
53 53
     }
54 54
 
55 55
     public function setAuthOptions(array $options){
56
-        foreach($this->authOptions as $key => $value){
56
+        foreach ($this->authOptions as $key => $value){
57 57
             if (isset($options[$key])){
58 58
                 $this->authOptions[$key] = $options[$key];
59 59
             }
@@ -61,27 +61,27 @@  discard block
 block discarded – undo
61 61
     }
62 62
 
63 63
     protected function registerSDKEntryPoints(){
64
-        require __DIR__ .DIRECTORY_SEPARATOR.'EntryPoint' .DIRECTORY_SEPARATOR.'registry.php';
65
-        foreach($entryPoints as $funcName => $className){
64
+        require __DIR__.DIRECTORY_SEPARATOR.'EntryPoint'.DIRECTORY_SEPARATOR.'registry.php';
65
+        foreach ($entryPoints as $funcName => $className){
66 66
             $className = "SugarAPI\\SDK\\EntryPoint\\".$className;
67
-            $this->registerEntryPoint($funcName,$className);
67
+            $this->registerEntryPoint($funcName, $className);
68 68
         }
69 69
     }
70 70
 
71
-    public function registerEntryPoint($funcName,$className){
71
+    public function registerEntryPoint($funcName, $className){
72 72
         if (isset($this->entryPoints[$funcName])){
73 73
             throw new SDKException('SDK method already defined. Method '.$funcName.' references Class '.$className);
74 74
         }
75 75
         $this->entryPoints[$funcName] = $className;
76 76
     }
77 77
 
78
-    public function __call($name,$params){
79
-        if (array_key_exists($name,$this->entryPoints)){
78
+    public function __call($name, $params){
79
+        if (array_key_exists($name, $this->entryPoints)){
80 80
             $Class = $this->entryPoints[$name];
81
-            $EntryPoint = new $Class($this->url,$params);
81
+            $EntryPoint = new $Class($this->url, $params);
82 82
 
83 83
             if ($EntryPoint->authRequired()){
84
-                if (isset($this->authToken)) {
84
+                if (isset($this->authToken)){
85 85
                     $EntryPoint->configureAuth($this->authToken->access_token);
86 86
                 }else{
87 87
                     throw new AuthenticationException('no_auth');
@@ -105,17 +105,17 @@  discard block
 block discarded – undo
105 105
         }
106 106
     }
107 107
     public function setInstance($instance){
108
-        if (strpos("https",$instance)!==FALSE){
108
+        if (strpos("https", $instance)!==FALSE){
109 109
             $this->secure = TRUE;
110 110
         }
111
-        if (strpos("http",$instance)===FALSE){
111
+        if (strpos("http", $instance)===FALSE){
112 112
             $instance = "http://".$instance;
113 113
         }
114
-        if (strpos("rest/v10",$instance)!==FALSE){
115
-            $instance = str_replace("rest/v10","",$instance);
114
+        if (strpos("rest/v10", $instance)!==FALSE){
115
+            $instance = str_replace("rest/v10", "", $instance);
116 116
         }
117 117
         $this->instance = $instance;
118
-        $this->url = rtrim($this->instance,"/").self::API_URL;
118
+        $this->url = rtrim($this->instance, "/").self::API_URL;
119 119
     }
120 120
     public function getURL(){
121 121
         return $this->url;
Please login to merge, or discard this patch.
src/EntryPoint/GET/RecordFileField.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -4,7 +4,7 @@
 block discarded – undo
4 4
 
5 5
 use SugarAPI\SDK\EntryPoint\Abstracts\GET\FileEntryPoint as GETFileEntryPoint;
6 6
 
7
-class RecordFileField extends GETFileEntryPoint{
7
+class RecordFileField extends GETFileEntryPoint {
8 8
 
9 9
     protected $_URL = '$module/$record/file/$field';
10 10
 
Please login to merge, or discard this patch.
src/EntryPoint/POST/CreateRecord.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -4,7 +4,7 @@
 block discarded – undo
4 4
 
5 5
 use SugarAPI\SDK\EntryPoint\Abstracts\POST\JSONEntryPoint as POSTEntryPoint;
6 6
 
7
-class CreateRecord extends POSTEntryPoint{
7
+class CreateRecord extends POSTEntryPoint {
8 8
 
9 9
     protected $_URL = '$module';
10 10
 
Please login to merge, or discard this patch.
src/Request/POSTFile.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -16,9 +16,9 @@
 block discarded – undo
16 16
      * Overrides POST setBody, so that Body is not json encoded
17 17
      * @inheritdoc
18 18
      */
19
-    public function setBody(array $body) {
19
+    public function setBody(array $body){
20 20
         $this->body = $body;
21
-        $this->setOption(CURLOPT_POSTFIELDS,$this->body);
21
+        $this->setOption(CURLOPT_POSTFIELDS, $this->body);
22 22
         return $this;
23 23
     }
24 24
 
Please login to merge, or discard this patch.
src/Request/POST.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -4,7 +4,7 @@  discard block
 block discarded – undo
4 4
 
5 5
 use SugarAPI\SDK\Request\Abstracts\AbstractRequest;
6 6
 
7
-class POST extends AbstractRequest{
7
+class POST extends AbstractRequest {
8 8
 
9 9
     /**
10 10
      * @inheritdoc
@@ -32,7 +32,7 @@  discard block
 block discarded – undo
32 32
      * JSON Encode Body
33 33
      * @inheritdoc
34 34
      */
35
-    public function setBody($body) {
35
+    public function setBody($body){
36 36
         return parent::setBody(json_encode($body));
37 37
     }
38 38
 }
39 39
\ No newline at end of file
Please login to merge, or discard this patch.
src/Request/Abstracts/AbstractRequest.php 1 patch
Spacing   +18 added lines, -18 removed lines patch added patch discarded remove patch
@@ -4,7 +4,7 @@  discard block
 block discarded – undo
4 4
 
5 5
 use SugarAPI\SDK\Request\Interfaces\RequestInterface;
6 6
 
7
-abstract class AbstractRequest implements RequestInterface{
7
+abstract class AbstractRequest implements RequestInterface {
8 8
 
9 9
     const STATUS_INIT = 'initialized';
10 10
     const STATUS_SENT = 'sent';
@@ -81,31 +81,31 @@  discard block
 block discarded – undo
81 81
             $this->setURL($url);
82 82
         }
83 83
         $this->setType();
84
-        foreach(static::$_DEFAULT_OPTIONS as $option => $value){
85
-            $this->setOption($option,$value);
84
+        foreach (static::$_DEFAULT_OPTIONS as $option => $value){
85
+            $this->setOption($option, $value);
86 86
         }
87 87
     }
88 88
 
89 89
     /**
90 90
      * @inheritdoc
91 91
      */
92
-    public function setURL($url) {
92
+    public function setURL($url){
93 93
         $this->url = $url;
94
-        $this->setOption(CURLOPT_URL,$this->url);
94
+        $this->setOption(CURLOPT_URL, $this->url);
95 95
         return $this;
96 96
     }
97 97
 
98 98
     /**
99 99
      * @inheritdoc
100 100
      */
101
-    public function getURL() {
101
+    public function getURL(){
102 102
         return $this->url;
103 103
     }
104 104
 
105 105
     /**
106 106
      * @inheritdoc
107 107
      */
108
-    public function addHeader($name, $value) {
108
+    public function addHeader($name, $value){
109 109
         $token = $name.": ".$value;
110 110
         $this->headers[] = $token;
111 111
         return $this;
@@ -114,9 +114,9 @@  discard block
 block discarded – undo
114 114
     /**
115 115
      * @inheritdoc
116 116
      */
117
-    public function setHeaders(array $array = array()) {
118
-        if (count($array)>0) {
119
-            foreach ($array as $key => $value) {
117
+    public function setHeaders(array $array = array()){
118
+        if (count($array)>0){
119
+            foreach ($array as $key => $value){
120 120
                 $this->addHeader($key, $value);
121 121
             }
122 122
         }
@@ -127,14 +127,14 @@  discard block
 block discarded – undo
127 127
     /**
128 128
      * @inheritdoc
129 129
      */
130
-    public function getHeaders() {
130
+    public function getHeaders(){
131 131
         return $this->headers;
132 132
     }
133 133
 
134 134
     /**
135 135
      * @inheritdoc
136 136
      */
137
-    public function setBody(array $body) {
137
+    public function setBody(array $body){
138 138
         $this->body = $body;
139 139
         $this->setOption(CURLOPT_POSTFIELDS, $this->body);
140 140
         return $this;
@@ -143,28 +143,28 @@  discard block
 block discarded – undo
143 143
     /**
144 144
      * @inheritdoc
145 145
      */
146
-    public function getBody() {
146
+    public function getBody(){
147 147
         return $this->body;
148 148
     }
149 149
 
150 150
     /**
151 151
      * @inheritdoc
152 152
      */
153
-    public function getCurlObject() {
153
+    public function getCurlObject(){
154 154
         return $this->CurlRequest;
155 155
     }
156 156
 
157 157
     /**
158 158
      * @inheritdoc
159 159
      */
160
-    public function setOption($option, $value) {
160
+    public function setOption($option, $value){
161 161
         curl_setopt($this->CurlRequest, $option, $value);
162 162
     }
163 163
 
164 164
     /**
165 165
      * @inheritdoc
166 166
      */
167
-    public function send() {
167
+    public function send(){
168 168
         $this->setHeaders();
169 169
         $this->CurlResponse = curl_exec($this->CurlRequest);
170 170
         $this->status = self::STATUS_SENT;
@@ -199,7 +199,7 @@  discard block
 block discarded – undo
199 199
     /**
200 200
      * @inheritdoc
201 201
      */
202
-    public function start() {
202
+    public function start(){
203 203
         $this->CurlRequest = curl_init();
204 204
         $this->status = self::STATUS_INIT;
205 205
         return $this;
@@ -218,7 +218,7 @@  discard block
 block discarded – undo
218 218
     /**
219 219
      * @inheritdoc
220 220
      */
221
-    public function getCurlStatus() {
221
+    public function getCurlStatus(){
222 222
         return $this->status;
223 223
     }
224 224
 }
225 225
\ No newline at end of file
Please login to merge, or discard this patch.
src/Request/PUT.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -4,7 +4,7 @@  discard block
 block discarded – undo
4 4
 
5 5
 use SugarAPI\SDK\Request\Abstracts\AbstractRequest;
6 6
 
7
-class PUT extends AbstractRequest{
7
+class PUT extends AbstractRequest {
8 8
 
9 9
     /**
10 10
      * @inheritdoc
@@ -32,7 +32,7 @@  discard block
 block discarded – undo
32 32
      * JSON Encode Body
33 33
      * @inheritdoc
34 34
      */
35
-    public function setBody(array $body) {
35
+    public function setBody(array $body){
36 36
         return parent::setBody(json_encode($body));
37 37
     }
38 38
 
Please login to merge, or discard this patch.