Completed
Push — master ( 15515b...fd48c6 )
by Mike
02:14
created
src/EntryPoint/POST/RecordFileField.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -20,10 +20,10 @@
 block discarded – undo
20 20
     /**
21 21
      * @inheritdoc
22 22
      */
23
-    public function data(array $data) {
24
-        foreach($data as $key => $value){
23
+    public function data(array $data){
24
+        foreach ($data as $key => $value){
25 25
             if (strtolower($key)!=='oauth_token' || strtolower($key)!=='delete_if_fails' || strtolower($key)!=='format'){
26
-                if (strpos($value,'@')===FALSE){
26
+                if (strpos($value, '@')===FALSE){
27 27
                     $data[$key] = '@'.$value;
28 28
                 }
29 29
             }
Please login to merge, or discard this patch.
src/SugarAPI.php 1 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.
examples/UploadFile.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -1,16 +1,16 @@  discard block
 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 5
 try{
6
-    $SugarAPI = new \SugarAPI\SDK\SugarAPI('instances.this/Ent/7700/',array('username' => 'admin','password'=>'asdf'));
6
+    $SugarAPI = new \SugarAPI\SDK\SugarAPI('instances.this/Ent/7700/', array('username' => 'admin', 'password'=>'asdf'));
7 7
     $SugarAPI->login();
8 8
     $EP = $SugarAPI->createRecord('Notes')->data(array('name' => 'Test Note'))->execute();
9 9
     $response = $EP->getResponse();
10 10
     if ($response->getStatus()=='200'){
11 11
         $record = $response->getBody();
12 12
 
13
-        $upload = $SugarAPI->attachFile('Notes',$record->id,'filename')->data(array(
13
+        $upload = $SugarAPI->attachFile('Notes', $record->id, 'filename')->data(array(
14 14
             'filename' => __DIR__.'/testfile.txt;filename=testfile.txt'
15 15
         ))->execute();
16 16
         $response = $upload->getResponse();
@@ -29,6 +29,6 @@  discard block
 block discarded – undo
29 29
         print_r($response->getBody());
30 30
     }
31 31
 
32
-}catch(\SugarAPI\SDK\Exception\SDKException $ex){
32
+}catch (\SugarAPI\SDK\Exception\SDKException $ex){
33 33
     print $ex->getMessage();
34 34
 }
35 35
\ No newline at end of file
Please login to merge, or discard this patch.