44
55use JiraRestApi \Configuration \ConfigurationInterface ;
66use JiraRestApi \Configuration \DotEnvConfiguration ;
7- use Monolog \Logger as Logger ;
87use Monolog \Handler \StreamHandler ;
8+ use Monolog \Logger as Logger ;
99
1010/**
1111 * Interact jira server with REST API.
@@ -58,13 +58,13 @@ class JiraClient
5858 * Constructor.
5959 *
6060 * @param ConfigurationInterface $configuration
61- * @param Logger $logger
62- * @param string $path
61+ * @param Logger $logger
62+ * @param string $path
6363 */
6464 public function __construct (ConfigurationInterface $ configuration = null , Logger $ logger = null , $ path = './ ' )
6565 {
6666 if ($ configuration === null ) {
67- if (!file_exists ($ path . '.env ' )) {
67+ if (!file_exists ($ path. '.env ' )) {
6868 // If calling the getcwd() on laravel it will returning the 'public' directory.
6969 $ path = '../ ' ;
7070 }
@@ -155,9 +155,9 @@ protected function filterNullVariable($haystack)
155155 * @param string $post_data
156156 * @param string $custom_request [PUT|DELETE]
157157 *
158- * @return string
159- *
160158 * @throws JiraException
159+ *
160+ * @return string
161161 */
162162 public function exec ($ context , $ post_data = null , $ custom_request = null )
163163 {
@@ -190,12 +190,12 @@ public function exec($context, $post_data = null, $custom_request = null)
190190 curl_setopt ($ ch , CURLOPT_SSL_VERIFYPEER , $ this ->getConfiguration ()->isCurlOptSslVerifyPeer ());
191191
192192 // 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 ' )) {
194194 curl_setopt ($ ch , CURLOPT_FOLLOWLOCATION , true );
195195 }
196-
196+
197197 curl_setopt ($ ch , CURLOPT_HTTPHEADER ,
198- array ( 'Accept: */* ' , 'Content-Type: application/json ' ) );
198+ [ 'Accept: */* ' , 'Content-Type: application/json ' ] );
199199
200200 curl_setopt ($ ch , CURLOPT_VERBOSE , $ this ->getConfiguration ()->isCurlOptVerbose ());
201201
@@ -217,7 +217,7 @@ public function exec($context, $post_data = null, $custom_request = null)
217217 }
218218
219219 // 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 );
221221
222222 $ this ->log ->addError ($ msg );
223223 throw new JiraException ($ msg );
@@ -255,12 +255,12 @@ private function createUploadHandle($url, $upload_file)
255255 // send file
256256 curl_setopt ($ ch , CURLOPT_POST , true );
257257
258- if (PHP_MAJOR_VERSION == 5 && PHP_MINOR_VERSION < 5 ) {
258+ if (PHP_MAJOR_VERSION == 5 && PHP_MINOR_VERSION < 5 ) {
259259 $ attachments = realpath ($ upload_file );
260260 $ filename = basename ($ upload_file );
261261
262262 curl_setopt ($ ch , CURLOPT_POSTFIELDS ,
263- array ( 'file ' => '@ ' .$ attachments .';filename= ' .$ filename) );
263+ [ 'file ' => '@ ' .$ attachments .';filename= ' .$ filename] );
264264
265265 $ this ->log ->addDebug ('using legacy file upload ' );
266266 } else {
@@ -269,7 +269,7 @@ private function createUploadHandle($url, $upload_file)
269269 $ attachments ->setPostFilename (basename ($ upload_file ));
270270
271271 curl_setopt ($ ch , CURLOPT_POSTFIELDS ,
272- array ( 'file ' => $ attachments) );
272+ [ 'file ' => $ attachments] );
273273
274274 $ this ->log ->addDebug ('using CURLFile= ' .var_export ($ attachments , true ));
275275 }
@@ -280,15 +280,15 @@ private function createUploadHandle($url, $upload_file)
280280 curl_setopt ($ ch , CURLOPT_SSL_VERIFYPEER , $ this ->getConfiguration ()->isCurlOptSslVerifyPeer ());
281281
282282 // 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 ' )) {
284284 curl_setopt ($ ch , CURLOPT_FOLLOWLOCATION , true );
285285 }
286286 curl_setopt ($ ch , CURLOPT_HTTPHEADER ,
287- array (
287+ [
288288 'Accept: */* ' ,
289289 'Content-Type: multipart/form-data ' ,
290290 'X-Atlassian-Token: nocheck ' ,
291- ) );
291+ ] );
292292
293293 curl_setopt ($ ch , CURLOPT_VERBOSE , $ this ->getConfiguration ()->isCurlOptVerbose ());
294294
@@ -303,9 +303,9 @@ private function createUploadHandle($url, $upload_file)
303303 * @param string $context url context
304304 * @param array $filePathArray upload file path.
305305 *
306- * @return array
307- *
308306 * @throws JiraException
307+ *
308+ * @return array
309309 */
310310 public function upload ($ context , $ filePathArray )
311311 {
@@ -314,8 +314,8 @@ public function upload($context, $filePathArray)
314314 // return value
315315 $ result_code = 200 ;
316316
317- $ chArr = array () ;
318- $ results = array () ;
317+ $ chArr = [] ;
318+ $ results = [] ;
319319 $ mh = curl_multi_init ();
320320
321321 for ($ idx = 0 ; $ idx < count ($ filePathArray ); ++$ idx ) {
@@ -363,7 +363,7 @@ public function upload($context, $filePathArray)
363363 if ($ this ->http_response != 200 && $ this ->http_response != 201 ) {
364364 $ body = 'CURL HTTP Request Failed: Status Code : '
365365 .$ this ->http_response .', URL: ' .$ url ;
366-
366+
367367 $ this ->log ->addError ($ body );
368368 }
369369 }
0 commit comments