4
4
5
5
use JiraRestApi \Configuration \ConfigurationInterface ;
6
6
use JiraRestApi \Configuration \DotEnvConfiguration ;
7
- use Monolog \Logger as Logger ;
8
7
use Monolog \Handler \StreamHandler ;
8
+ use Monolog \Logger as Logger ;
9
9
10
10
/**
11
11
* Interact jira server with REST API.
@@ -58,13 +58,13 @@ class JiraClient
58
58
* Constructor.
59
59
*
60
60
* @param ConfigurationInterface $configuration
61
- * @param Logger $logger
62
- * @param string $path
61
+ * @param Logger $logger
62
+ * @param string $path
63
63
*/
64
64
public function __construct (ConfigurationInterface $ configuration = null , Logger $ logger = null , $ path = './ ' )
65
65
{
66
66
if ($ configuration === null ) {
67
- if (!file_exists ($ path . '.env ' )) {
67
+ if (!file_exists ($ path. '.env ' )) {
68
68
// If calling the getcwd() on laravel it will returning the 'public' directory.
69
69
$ path = '../ ' ;
70
70
}
@@ -155,9 +155,9 @@ protected function filterNullVariable($haystack)
155
155
* @param string $post_data
156
156
* @param string $custom_request [PUT|DELETE]
157
157
*
158
- * @return string
159
- *
160
158
* @throws JiraException
159
+ *
160
+ * @return string
161
161
*/
162
162
public function exec ($ context , $ post_data = null , $ custom_request = null )
163
163
{
@@ -190,12 +190,12 @@ public function exec($context, $post_data = null, $custom_request = null)
190
190
curl_setopt ($ ch , CURLOPT_SSL_VERIFYPEER , $ this ->getConfiguration ()->isCurlOptSslVerifyPeer ());
191
191
192
192
// curl_setopt(): CURLOPT_FOLLOWLOCATION cannot be activated when an open_basedir is set
193
- if (!function_exists ('ini_get ' ) || !ini_get ('open_basedir ' )){
193
+ if (!function_exists ('ini_get ' ) || !ini_get ('open_basedir ' )) {
194
194
curl_setopt ($ ch , CURLOPT_FOLLOWLOCATION , true );
195
195
}
196
-
196
+
197
197
curl_setopt ($ ch , CURLOPT_HTTPHEADER ,
198
- array ( 'Accept: */* ' , 'Content-Type: application/json ' ) );
198
+ [ 'Accept: */* ' , 'Content-Type: application/json ' ] );
199
199
200
200
curl_setopt ($ ch , CURLOPT_VERBOSE , $ this ->getConfiguration ()->isCurlOptVerbose ());
201
201
@@ -217,7 +217,7 @@ public function exec($context, $post_data = null, $custom_request = null)
217
217
}
218
218
219
219
// HostNotFound, No route to Host, etc Network error
220
- $ msg = sprintf (" CURL Error: http response=%d, %s " , $ this ->http_response , $ body );
220
+ $ msg = sprintf (' CURL Error: http response=%d, %s ' , $ this ->http_response , $ body );
221
221
222
222
$ this ->log ->addError ($ msg );
223
223
throw new JiraException ($ msg );
@@ -255,12 +255,12 @@ private function createUploadHandle($url, $upload_file)
255
255
// send file
256
256
curl_setopt ($ ch , CURLOPT_POST , true );
257
257
258
- if (PHP_MAJOR_VERSION == 5 && PHP_MINOR_VERSION < 5 ) {
258
+ if (PHP_MAJOR_VERSION == 5 && PHP_MINOR_VERSION < 5 ) {
259
259
$ attachments = realpath ($ upload_file );
260
260
$ filename = basename ($ upload_file );
261
261
262
262
curl_setopt ($ ch , CURLOPT_POSTFIELDS ,
263
- array ( 'file ' => '@ ' .$ attachments .';filename= ' .$ filename) );
263
+ [ 'file ' => '@ ' .$ attachments .';filename= ' .$ filename] );
264
264
265
265
$ this ->log ->addDebug ('using legacy file upload ' );
266
266
} else {
@@ -269,7 +269,7 @@ private function createUploadHandle($url, $upload_file)
269
269
$ attachments ->setPostFilename (basename ($ upload_file ));
270
270
271
271
curl_setopt ($ ch , CURLOPT_POSTFIELDS ,
272
- array ( 'file ' => $ attachments) );
272
+ [ 'file ' => $ attachments] );
273
273
274
274
$ this ->log ->addDebug ('using CURLFile= ' .var_export ($ attachments , true ));
275
275
}
@@ -280,15 +280,15 @@ private function createUploadHandle($url, $upload_file)
280
280
curl_setopt ($ ch , CURLOPT_SSL_VERIFYPEER , $ this ->getConfiguration ()->isCurlOptSslVerifyPeer ());
281
281
282
282
// curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true); cannot be activated when an open_basedir is set
283
- if (!function_exists ('ini_get ' ) || !ini_get ('open_basedir ' )){
283
+ if (!function_exists ('ini_get ' ) || !ini_get ('open_basedir ' )) {
284
284
curl_setopt ($ ch , CURLOPT_FOLLOWLOCATION , true );
285
285
}
286
286
curl_setopt ($ ch , CURLOPT_HTTPHEADER ,
287
- array (
287
+ [
288
288
'Accept: */* ' ,
289
289
'Content-Type: multipart/form-data ' ,
290
290
'X-Atlassian-Token: nocheck ' ,
291
- ) );
291
+ ] );
292
292
293
293
curl_setopt ($ ch , CURLOPT_VERBOSE , $ this ->getConfiguration ()->isCurlOptVerbose ());
294
294
@@ -303,9 +303,9 @@ private function createUploadHandle($url, $upload_file)
303
303
* @param string $context url context
304
304
* @param array $filePathArray upload file path.
305
305
*
306
- * @return array
307
- *
308
306
* @throws JiraException
307
+ *
308
+ * @return array
309
309
*/
310
310
public function upload ($ context , $ filePathArray )
311
311
{
@@ -314,8 +314,8 @@ public function upload($context, $filePathArray)
314
314
// return value
315
315
$ result_code = 200 ;
316
316
317
- $ chArr = array () ;
318
- $ results = array () ;
317
+ $ chArr = [] ;
318
+ $ results = [] ;
319
319
$ mh = curl_multi_init ();
320
320
321
321
for ($ idx = 0 ; $ idx < count ($ filePathArray ); ++$ idx ) {
@@ -363,7 +363,7 @@ public function upload($context, $filePathArray)
363
363
if ($ this ->http_response != 200 && $ this ->http_response != 201 ) {
364
364
$ body = 'CURL HTTP Request Failed: Status Code : '
365
365
.$ this ->http_response .', URL: ' .$ url ;
366
-
366
+
367
367
$ this ->log ->addError ($ body );
368
368
}
369
369
}
0 commit comments