Completed
Push — master ( 1bb428...fe8713 )
by Tobias
8s
created
bootstrap.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -18,4 +18,4 @@
 block discarded – undo
18 18
 along with this program.  If not, see <http://www.gnu.org/licenses/>.
19 19
 */
20 20
 
21
-include __DIR__ . '/src/autoload.php';
22 21
\ No newline at end of file
22
+include __DIR__.'/src/autoload.php';
23 23
\ No newline at end of file
Please login to merge, or discard this patch.
src/autoload.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -31,14 +31,14 @@  discard block
 block discarded – undo
31 31
  * @return void
32 32
  * @link https://github.com/php-fig/fig-standards/blob/master/accepted/PSR-4-autoloader-examples.md
33 33
  */
34
-spl_autoload_register(function ($class) {
34
+spl_autoload_register(function($class) {
35 35
 
36 36
     // project-specific namespace prefix
37 37
     $prefix = 'FreeIPA\\';
38 38
 
39 39
     // base directory for the namespace prefix
40 40
     // $base_dir = __DIR__ . '/src/';
41
-    $base_dir = __DIR__ . '/';
41
+    $base_dir = __DIR__.'/';
42 42
 
43 43
     // does the class use the namespace prefix?
44 44
     $len = strlen($prefix);
@@ -53,7 +53,7 @@  discard block
 block discarded – undo
53 53
     // replace the namespace prefix with the base directory, replace namespace
54 54
     // separators with directory separators in the relative class name, append
55 55
     // with .php
56
-    $file = $base_dir . str_replace('\\', '/', $relative_class) . '.php';
56
+    $file = $base_dir.str_replace('\\', '/', $relative_class).'.php';
57 57
 
58 58
     // if the file exists, require it
59 59
     if (file_exists($file)) {
Please login to merge, or discard this patch.
src/APIAccess/Connection.php 4 patches
Doc Comments   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -323,7 +323,7 @@  discard block
 block discarded – undo
323 323
      * Get the server address (IP or hostname)
324 324
      *
325 325
      * @param void
326
-     * @return string|bool
326
+     * @return string|null
327 327
      * @sice GIT 0.1.0
328 328
      * @version GIT: 0.1.0
329 329
      * @see setIPAServer()
@@ -360,7 +360,7 @@  discard block
 block discarded – undo
360 360
     /**
361 361
      * Get the full path of certificate file
362 362
      *
363
-     * @return string|bool
363
+     * @return string|null
364 364
      * @sice GIT 0.1.0
365 365
      * @version GIT: 0.1.0
366 366
      * @see setCertificateFile()
@@ -388,7 +388,7 @@  discard block
 block discarded – undo
388 388
      * Get the string returned by cURL
389 389
      *
390 390
      * @param void
391
-     * @return string|bool
391
+     * @return string|null
392 392
      * @sice GIT 0.1.0
393 393
      * @version GIT: 0.1.0
394 394
      * @see setCurlReturn()
@@ -429,7 +429,7 @@  discard block
 block discarded – undo
429 429
      * Get the cURL handler with options already defined
430 430
      *
431 431
      * @param bool $force force cURL to be initiated again
432
-     * @return mixed cURL handler
432
+     * @return boolean cURL handler
433 433
      * @sice GIT 0.1.0
434 434
      * @version GIT: 0.1.0
435 435
      * @see endCurl()
@@ -785,7 +785,7 @@  discard block
 block discarded – undo
785 785
      * @param string $method required parameter that defines the method that will be executed in the server
786 786
      * @param array $args arguments for the method
787 787
      * @param array $options options for the method
788
-     * @return string|bool returns false if there is error in passed parameters
788
+     * @return false|string returns false if there is error in passed parameters
789 789
      * @sice GIT 0.1.0
790 790
      * @version GIT: 0.1.0
791 791
      * @link http://php.net/manual/en/function.json-encode.php
Please login to merge, or discard this patch.
Indentation   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -267,7 +267,7 @@
 block discarded – undo
267 267
                 break;
268 268
         }
269 269
         return($r);
270
-	}
270
+  }
271 271
 
272 272
     /**
273 273
      * Define a version that will be used in json sent to the server. The server will refuse
Please login to merge, or discard this patch.
Spacing   +34 added lines, -34 removed lines patch added patch discarded remove patch
@@ -112,7 +112,7 @@  discard block
 block discarded – undo
112 112
      * @access public
113 113
      * @sice GIT 0.1.0
114 114
      */
115
-    protected $certificate_file  = null;
115
+    protected $certificate_file = null;
116 116
 
117 117
     /**
118 118
      * @var array curl_http_header HTTP header that will be used with cURL
@@ -147,7 +147,7 @@  discard block
 block discarded – undo
147 147
      * @access protected
148 148
      * @sice GIT 0.1.0
149 149
      */
150
-    protected $user_logged  = false;
150
+    protected $user_logged = false;
151 151
     
152 152
     /**
153 153
      * @var string|null $json_request String that contains the last json request what will be (or was) sent to the server
@@ -196,14 +196,14 @@  discard block
 block discarded – undo
196 196
      * @throws \Exception caso o método setCertificateFile() retorne false
197 197
      */
198 198
     private function __construct($server = null, $certificate = null) {
199
-        if (! function_exists('curl_init')) {
199
+        if ( ! function_exists('curl_init')) {
200 200
             throw new \Exception('Unable to find cURL');
201 201
         }
202 202
         
203
-        if ( ! empty($server) && ! $this->setIPAServer($server) ) {
203
+        if ( ! empty($server) && ! $this->setIPAServer($server)) {
204 204
             throw new \Exception("Error while validating the server");
205 205
         }
206
-        else if ( ! empty($certificate) && ! $this->setCertificateFile($certificate) ) {
206
+        else if ( ! empty($certificate) && ! $this->setCertificateFile($certificate)) {
207 207
             throw new \Exception("Error while validating the certificate");
208 208
         }
209 209
         
@@ -257,7 +257,7 @@  discard block
 block discarded – undo
257 257
     {
258 258
         switch ($force_new) {
259 259
             case false:
260
-                if (! isset(self::$_instance)) {
260
+                if ( ! isset(self::$_instance)) {
261 261
                     self::$_instance = new self($server, $certificate);
262 262
                 }
263 263
                 $r = self::$_instance;
@@ -310,12 +310,12 @@  discard block
 block discarded – undo
310 310
      */
311 311
     public function setIPAServer($host = null)
312 312
     {
313
-        if (empty($host) || is_null($host) || !is_string($host)) {
313
+        if (empty($host) || is_null($host) || ! is_string($host)) {
314 314
             return false;
315 315
         }
316 316
         $this->ipa_server = $host;
317
-        $this->jsonrpc_url = 'https://' . $host . '/ipa/session/json';
318
-        $this->jsonrpc_login_url = 'https://' . $host . '/ipa/session/login_password';
317
+        $this->jsonrpc_url = 'https://'.$host.'/ipa/session/json';
318
+        $this->jsonrpc_login_url = 'https://'.$host.'/ipa/session/login_password';
319 319
         return true;
320 320
     }
321 321
 
@@ -346,11 +346,11 @@  discard block
 block discarded – undo
346 346
      */
347 347
     public function setCertificateFile($file)
348 348
     {
349
-        if (empty($file) || is_null($file) || !is_string($file)) {
349
+        if (empty($file) || is_null($file) || ! is_string($file)) {
350 350
             return false;
351
-        } else if (!file_exists($file)) {
351
+        } else if ( ! file_exists($file)) {
352 352
             throw new \Exception("Certificate file doesn't exists");
353
-        } else if (!is_readable($file)) {
353
+        } else if ( ! is_readable($file)) {
354 354
             throw new \Exception("Certificate file can't be read");
355 355
         }
356 356
         $this->certificate_file = $file;
@@ -531,7 +531,7 @@  discard block
 block discarded – undo
531 531
      */
532 532
     public function curlHaveError()
533 533
     {
534
-        return ( curl_errno($this->curl_handler) ) ? true : false;
534
+        return (curl_errno($this->curl_handler)) ? true : false;
535 535
     }
536 536
 
537 537
     /**
@@ -615,14 +615,14 @@  discard block
 block discarded – undo
615 615
             return true;
616 616
         }
617 617
         
618
-        if (!$user || !$password) {
618
+        if ( ! $user || ! $password) {
619 619
             return false;
620 620
         }
621 621
         
622
-        if (! $this->getIPAServer()) {
622
+        if ( ! $this->getIPAServer()) {
623 623
             throw new \Exception("Error while validating the server");
624 624
         }
625
-        if (! $this->getCertificateFile()) {
625
+        if ( ! $this->getCertificateFile()) {
626 626
             throw new \Exception("Error while validating the certificate");
627 627
         }
628 628
 
@@ -648,11 +648,11 @@  discard block
 block discarded – undo
648 648
         //$password = urlencode($password);
649 649
 
650 650
         curl_setopt($this->curl_handler, CURLOPT_HTTPHEADER, $this->curl_http_header);
651
-        curl_setopt($this->curl_handler, CURLOPT_URL,        $this->jsonrpc_login_url);
651
+        curl_setopt($this->curl_handler, CURLOPT_URL, $this->jsonrpc_login_url);
652 652
         curl_setopt($this->curl_handler, CURLOPT_POSTFIELDS, "user=$user&password=$password");
653 653
         // I need header for get the value for X-IPA-Rejection-Reason field
654 654
         // and as workaround_for_auth
655
-        if (! $this->curl_debug) {
655
+        if ( ! $this->curl_debug) {
656 656
             curl_setopt($this->curl_handler, CURLOPT_HEADER, true);
657 657
         }
658 658
 
@@ -670,7 +670,7 @@  discard block
 block discarded – undo
670 670
 
671 671
         // I need header for get the value for X-IPA-Rejection-Reason field
672 672
         // and as workaround_for_auth
673
-        if (!$this->curl_debug) {
673
+        if ( ! $this->curl_debug) {
674 674
             curl_setopt($this->curl_handler, CURLOPT_HEADER, false);
675 675
         }
676 676
 
@@ -695,15 +695,15 @@  discard block
 block discarded – undo
695 695
                 $auth_info['message'] .= 'Unable to find user in the server. ';
696 696
             } else {
697 697
                 $auth_info['message'] .= 'Generic error in authentication. ';
698
-                if (! empty($ipa_error_description)) {
699
-                    $auth_info['message'] .= "The server returned \"" . $ipa_error_description . "\". ";
698
+                if ( ! empty($ipa_error_description)) {
699
+                    $auth_info['message'] .= "The server returned \"".$ipa_error_description."\". ";
700 700
                 }
701 701
             }
702 702
         } else if ('200' != $auth_info['http_code']) {
703 703
             $auth_info['authenticate'] = false;
704
-            $auth_info['message'] = "The response returned the HTTP code \"" . $auth_info['http_code'] . "\" that is not acceptable. ";
705
-            if (!empty($ipa_error_description)) {
706
-                $auth_info['message'] .= "The server returned \"" . $ipa_error_description . "\". ";
704
+            $auth_info['message'] = "The response returned the HTTP code \"".$auth_info['http_code']."\" that is not acceptable. ";
705
+            if ( ! empty($ipa_error_description)) {
706
+                $auth_info['message'] .= "The server returned \"".$ipa_error_description."\". ";
707 707
             }
708 708
         } else {
709 709
             $auth_info['authenticate'] = true;
@@ -768,11 +768,11 @@  discard block
 block discarded – undo
768 768
      */
769 769
     public function isAssociativeArray($var, $force = true)
770 770
     {
771
-        if (!is_array($var)) {
771
+        if ( ! is_array($var)) {
772 772
             return false;
773 773
         }
774 774
 
775
-        if (!empty($var) || $force) {
775
+        if ( ! empty($var) || $force) {
776 776
             return array_diff_key($var, array_keys(array_keys($var)));
777 777
         }
778 778
 
@@ -792,7 +792,7 @@  discard block
 block discarded – undo
792 792
      */
793 793
     public function buildJsonRequest($method = null, $args = array(), $options = array())
794 794
     {
795
-        if (!$method || !is_array($args) || !$this->isAssociativeArray($options, false)) {
795
+        if ( ! $method || ! is_array($args) || ! $this->isAssociativeArray($options, false)) {
796 796
             return false;
797 797
         }
798 798
 
@@ -850,7 +850,7 @@  discard block
 block discarded – undo
850 850
      */
851 851
     public function buildRequest($method = null, $params = array(), $options = array(), $exceptionInError = true)
852 852
     {
853
-        if (!$this->userLogged()) {
853
+        if ( ! $this->userLogged()) {
854 854
             throw new \Exception('User is not logged in');
855 855
         }
856 856
 
@@ -863,10 +863,10 @@  discard block
 block discarded – undo
863 863
             CURLOPT_URL => $this->jsonrpc_url,
864 864
             CURLOPT_POSTFIELDS => $json,
865 865
             CURLOPT_HTTPHEADER => array(
866
-                'referer:https://' . $this->ipa_server . '/ipa/ui/index.html',
866
+                'referer:https://'.$this->ipa_server.'/ipa/ui/index.html',
867 867
                 'Content-Type:application/json',
868 868
                 'Accept:applicaton/json',
869
-                'Content-Length: ' . strlen($json),
869
+                'Content-Length: '.strlen($json),
870 870
             ),
871 871
         );
872 872
 
@@ -881,15 +881,15 @@  discard block
 block discarded – undo
881 881
         if ($this->curlHaveError()) {
882 882
             throw new \Exception('Error in cURL request');
883 883
         }
884
-        if (!$response_http_code || '200' != $response_http_code) {
884
+        if ( ! $response_http_code || '200' != $response_http_code) {
885 885
             throw new \Exception("The value \"$response_http_code\" is not a valid response code");
886 886
         }
887 887
         if (empty($json_retorno) || empty($object_json_returned)) {
888 888
             #TODO criar exceção para passar os dados do erro ao inves do json puro. Vide arquivo exemplos_retornos.txt
889 889
             throw new \Exception("Erro in json return. Value is ${json_retorno}");
890 890
         }
891
-        if ($exceptionInError && !empty($object_json_returned->error)) {
892
-            throw new \Exception("Error in request. Details: " . $object_json_returned->error->message, $object_json_returned->error->code);
891
+        if ($exceptionInError && ! empty($object_json_returned->error)) {
892
+            throw new \Exception("Error in request. Details: ".$object_json_returned->error->message, $object_json_returned->error->code);
893 893
         }
894 894
 
895 895
         return array($object_json_returned, $response_http_code);
@@ -908,7 +908,7 @@  discard block
 block discarded – undo
908 908
     {
909 909
         $ret = $this->buildRequest('ping'); // receives json and http response code
910 910
         $json = $ret[0];
911
-        if (!empty($json->error) || empty($json->result) || empty($json->result->summary) || !is_string($json->result->summary)) {
911
+        if ( ! empty($json->error) || empty($json->result) || empty($json->result->summary) || ! is_string($json->result->summary)) {
912 912
             return false;
913 913
         }
914 914
         if ($return_string) {
Please login to merge, or discard this patch.
Braces   +1 added lines, -2 removed lines patch added patch discarded remove patch
@@ -189,8 +189,7 @@
 block discarded – undo
189 189
 
190 190
         if ( ! empty($server) && ! $this->setIPAServer($server) ) {
191 191
             throw new \Exception("Error while validating the server");
192
-        }
193
-        else if ( ! empty($certificate) && ! $this->setCertificateFile($certificate) ) {
192
+        } else if ( ! empty($certificate) && ! $this->setCertificateFile($certificate) ) {
194 193
             throw new \Exception("Error while validating the certificate");
195 194
         }
196 195
 
Please login to merge, or discard this patch.
src/APIAccess/User.php 1 patch
Spacing   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -55,7 +55,7 @@  discard block
 block discarded – undo
55 55
      */
56 56
     public function find($args = array(), $options = array())
57 57
     {
58
-        if (!is_array($args) || !is_array($options)) {
58
+        if ( ! is_array($args) || ! is_array($options)) {
59 59
             return false;
60 60
         }
61 61
 
@@ -72,11 +72,11 @@  discard block
 block discarded – undo
72 72
         $return_request = $this->getConnection()->buildRequest('user_find', $args, $final_options); //returns json and http code of response
73 73
         $json = $return_request[0];
74 74
 
75
-        if (empty($json->result) || !isset($json->result->count)) {
75
+        if (empty($json->result) || ! isset($json->result->count)) {
76 76
             throw new \Exception('Malformed json');
77 77
         }
78 78
 
79
-        if ($json->result->count < 1) {
79
+        if ($json->result->count<1) {
80 80
             return false;
81 81
         }
82 82
 
@@ -104,7 +104,7 @@  discard block
 block discarded – undo
104 104
      */
105 105
     public function findBy($field = null, $value = null)
106 106
     {
107
-        if (!$field || !$value) {
107
+        if ( ! $field || ! $value) {
108 108
             return false;
109 109
         }
110 110
 
@@ -126,7 +126,7 @@  discard block
 block discarded – undo
126 126
      */
127 127
     public function get($params = null, $options = array())
128 128
     {
129
-        if (!is_array($options)) {
129
+        if ( ! is_array($options)) {
130 130
             return false;
131 131
         }
132 132
 
@@ -150,7 +150,7 @@  discard block
 block discarded – undo
150 150
         $return_request = $this->getConnection()->buildRequest('user_show', $final_params, $final_options, false);
151 151
         $json = $return_request[0];
152 152
 
153
-        if (!empty($json->error) && strtolower($json->error->name) == 'notfound') {
153
+        if ( ! empty($json->error) && strtolower($json->error->name) == 'notfound') {
154 154
             // user not found
155 155
             return false;
156 156
         }
@@ -160,7 +160,7 @@  discard block
 block discarded – undo
160 160
         }
161 161
 
162 162
         // #TODO erase this code?
163
-        if (!isset($json->result->result)) {
163
+        if ( ! isset($json->result->result)) {
164 164
             return false;
165 165
         }
166 166
 
@@ -185,7 +185,7 @@  discard block
 block discarded – undo
185 185
      */
186 186
     public function add($data)
187 187
     {
188
-        if (!$data || !isset($data['uid']) || empty($data['uid'])) {
188
+        if ( ! $data || ! isset($data['uid']) || empty($data['uid'])) {
189 189
             return false;
190 190
         }
191 191
 
@@ -204,7 +204,7 @@  discard block
 block discarded – undo
204 204
 
205 205
         // The buildRequest() method already checks the field 'error', which is the only relevant to this API method
206 206
         $return_request = $this->getConnection()->buildRequest('user_add', $args, $final_options); //returns json and http code of response
207
-        if (!$return_request) {
207
+        if ( ! $return_request) {
208 208
             return false;
209 209
         }
210 210
 
@@ -239,7 +239,7 @@  discard block
 block discarded – undo
239 239
      */
240 240
     public function modify($login = null, $data = array())
241 241
     {
242
-        if (!$login || !$data) {
242
+        if ( ! $login || ! $data) {
243 243
             return false;
244 244
         }
245 245
 
@@ -256,7 +256,7 @@  discard block
 block discarded – undo
256 256
 
257 257
         // The buildRequest() method already checks the field 'error', which is the only relevant to this API method
258 258
         $return_request = $this->getConnection()->buildRequest('user_mod', $args, $final_options); //returns json and http code of response
259
-        if (!$return_request) {
259
+        if ( ! $return_request) {
260 260
             return false;
261 261
         }
262 262
 
Please login to merge, or discard this patch.
src/APIAccess/Group.php 1 patch
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -54,7 +54,7 @@  discard block
 block discarded – undo
54 54
      */
55 55
     public function add($name = null, $data = array())
56 56
     {
57
-        if (!$name || !$data) {
57
+        if ( ! $name || ! $data) {
58 58
             return false;
59 59
         }
60 60
 
@@ -77,7 +77,7 @@  discard block
 block discarded – undo
77 77
 
78 78
         // The buildRequest() method already checks the field 'error', which is the only relevant to this API method
79 79
         $response = $this->getConnection()->buildRequest('group_add', $args, $final_options); //returns json and http code of response
80
-        if (!$response) {
80
+        if ( ! $response) {
81 81
             return false;
82 82
         }
83 83
 
@@ -102,7 +102,7 @@  discard block
 block discarded – undo
102 102
      */
103 103
     public function addMember($group_name = null, $data = array())
104 104
     {
105
-        if (!$group_name || !$data) {
105
+        if ( ! $group_name || ! $data) {
106 106
             return false;
107 107
         }
108 108
 
@@ -122,22 +122,22 @@  discard block
 block discarded – undo
122 122
         }
123 123
 
124 124
         $response = $this->getConnection()->buildRequest('group_add_member', $args, $final_options); //returns json and http code of response
125
-        if (!$response) {
125
+        if ( ! $response) {
126 126
             return false;
127 127
         }
128 128
         $returned_json = $response[0];
129
-        if (!$returned_json->result->completed) {
129
+        if ( ! $returned_json->result->completed) {
130 130
             $message = "Error while inserting members in group \"$group_name\".";
131
-            if (!empty($returned_json->result->failed->member->group) ||
132
-            !empty($returned_json->result->failed->member->user)) {
131
+            if ( ! empty($returned_json->result->failed->member->group) ||
132
+            ! empty($returned_json->result->failed->member->user)) {
133 133
                 $message .= 'Details: ';
134 134
             }
135 135
 
136
-            if (!empty($returned_json->result->failed->member->group)) {
136
+            if ( ! empty($returned_json->result->failed->member->group)) {
137 137
                 $message .= implode(' ', $returned_json->result->failed->member->group[0]);
138 138
             }
139 139
 
140
-            if (!empty($returned_json->result->failed->member->user)) {
140
+            if ( ! empty($returned_json->result->failed->member->user)) {
141 141
                 $message .= implode(' ', $returned_json->result->failed->member->user[0]);
142 142
             }
143 143
 
Please login to merge, or discard this patch.
src/APIAccess/Main.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -74,7 +74,7 @@
 block discarded – undo
74 74
      */
75 75
     public function connection($server = null, $certificate = null)
76 76
     {
77
-        if (! $this->_connection) {
77
+        if ( ! $this->_connection) {
78 78
             $this->_connection = \FreeIPA\APIAccess\Connection::getInstance($server, $certificate);
79 79
         }
80 80
         return($this->_connection);
Please login to merge, or discard this patch.
examples/all.php 1 patch
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -21,16 +21,16 @@  discard block
 block discarded – undo
21 21
  * This file contains examples of utilization of this library
22 22
  */
23 23
 
24
-ini_set( 'display_errors', 1);
25
-ini_set( 'track_errors',   1);
26
-ini_set( 'html_errors',    1);
27
-error_reporting( E_ALL );
24
+ini_set('display_errors', 1);
25
+ini_set('track_errors', 1);
26
+ini_set('html_errors', 1);
27
+error_reporting(E_ALL);
28 28
 
29
-require_once( 'functions_utils.php' );
29
+require_once('functions_utils.php');
30 30
 
31 31
 $host = 'ipa.demo1.freeipa.org';
32 32
 // The certificate can be obtained in https://$host/ipa/config/ca.crt
33
-$certificate = __DIR__ . "/../certs/ipa.demo1.freeipa.org_ca.crt";
33
+$certificate = __DIR__."/../certs/ipa.demo1.freeipa.org_ca.crt";
34 34
 $user = 'admin';
35 35
 $password = 'Secret123';
36 36
 $search = 'test';
@@ -109,8 +109,8 @@  discard block
 block discarded – undo
109 109
     if ($ret_search_users) {
110 110
         $t = count($ret_search_users);
111 111
         print "Found $t usuários. Names: ";
112
-        for ($i = 0; $i < $t; $i++) {
113
-            print $ret_search_users[$i]->uid[0] . " | ";
112
+        for ($i = 0; $i<$t; $i++) {
113
+            print $ret_search_users[$i]->uid[0]." | ";
114 114
         }
115 115
         _print();
116 116
     } else {
Please login to merge, or discard this patch.
examples/functions_utils.php 2 patches
Indentation   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -4,18 +4,18 @@
 block discarded – undo
4 4
  * Print a message
5 5
  */
6 6
 function _print( $string = NULL ) {
7
-	if ( 'cli' == php_sapi_name() ) { // PHP is running in terminal
8
-		$line_end = PHP_EOL;
9
-	} else {
10
-		$line_end = '<br/>';
11
-	}
7
+  if ( 'cli' == php_sapi_name() ) { // PHP is running in terminal
8
+    $line_end = PHP_EOL;
9
+  } else {
10
+    $line_end = '<br/>';
11
+  }
12 12
 
13
-	if ( ! empty( $string ) ) {
14
-		$file   = basename( $_SERVER["PHP_SELF"] );
15
-		$output = date( 'd-m-Y_H:i:s ' ) . "[$file] $string $line_end";
16
-	} else {
17
-		$output = $line_end;
18
-	}
13
+  if ( ! empty( $string ) ) {
14
+    $file   = basename( $_SERVER["PHP_SELF"] );
15
+    $output = date( 'd-m-Y_H:i:s ' ) . "[$file] $string $line_end";
16
+  } else {
17
+    $output = $line_end;
18
+  }
19 19
 
20
-	print ( $output );
20
+  print ( $output );
21 21
 }
Please login to merge, or discard this patch.
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -3,19 +3,19 @@
 block discarded – undo
3 3
 /**
4 4
  * Print a message
5 5
  */
6
-function _print( $string = NULL ) {
7
-	if ( 'cli' == php_sapi_name() ) { // PHP is running in terminal
6
+function _print($string = NULL) {
7
+	if ('cli' == php_sapi_name()) { // PHP is running in terminal
8 8
 		$line_end = PHP_EOL;
9 9
 	} else {
10 10
 		$line_end = '<br/>';
11 11
 	}
12 12
 
13
-	if ( ! empty( $string ) ) {
14
-		$file   = basename( $_SERVER["PHP_SELF"] );
15
-		$output = date( 'd-m-Y_H:i:s ' ) . "[$file] $string $line_end";
13
+	if ( ! empty($string)) {
14
+		$file   = basename($_SERVER["PHP_SELF"]);
15
+		$output = date('d-m-Y_H:i:s ')."[$file] $string $line_end";
16 16
 	} else {
17 17
 		$output = $line_end;
18 18
 	}
19 19
 
20
-	print ( $output );
20
+	print ($output);
21 21
 }
Please login to merge, or discard this patch.