@@ -35,18 +35,17 @@ class JiraClient {
3535 /** @var Monolog instance */
3636 protected $ log ;
3737
38- private $ options = array (
39- // disable SSL Certification validation
40- CURLOPT_SSL_VERIFYHOST => 0 ,
41- // FALSE to stop CURL from verifying the peer's certificate.
42- CURLOPT_SSL_VERIFYPEER => 0 ,
38+ // disable SSL Certification validation
39+ protected $ CURLOPT_SSL_VERIFYHOST = false ;
40+ // FALSE to stop CURL from verifying the peer's certificate.
41+ protected $ CURLOPT_SSL_VERIFYPEER = false ;
4342
44- CURLOPT_VERBOSE => true ,
45-
46- 'LOG_FILE ' => 'jira-rest-client.log ' ,
47- 'LOG_LEVEL ' => Logger::INFO ,
48- );
43+ // debug curl
44+ protected $ CURLOPT_VERBOSE = false ;
4945
46+ protected $ LOG_FILE = 'jira-rest-client.log ' ;
47+ protected $ LOG_LEVEL = Logger::INFO ;
48+
5049 private function convertLogLevel ($ log_level ) {
5150 if ($ log_level == 'DEBUG ' )
5251 return Logger::DEBUG ;
@@ -58,7 +57,7 @@ private function convertLogLevel($log_level) {
5857 return Logger::INFO ;
5958 }
6059
61- public function __construct ($ config, $ options = null )
60+ public function __construct ($ config )
6261 {
6362 $ this ->json_mapper = new \JsonMapper ();
6463 $ this ->json_mapper ->bExceptionOnUndefinedProperty = true ;
@@ -67,25 +66,25 @@ public function __construct($config, $options = null)
6766 $ this ->username = $ config ['username ' ];
6867 $ this ->password = $ config ['password ' ];
6968
70- if (!is_null ($ options )) {
71- //http://stackoverflow.com/questions/5929642/php-array-merge-with-numerical-keys
72- // array_merge with numeric key
73- $ this ->options = $ this ->options + $ options ;
74- //$this->options = array_merge($this->options, $options);
69+ if (isset ($ config ['CURLOPT_SSL_VERIFYHOST ' ]))
70+ $ this ->CURLOPT_SSL_VERIFYHOST = $ config ['CURLOPT_SSL_VERIFYHOST ' ] === 'true ' ? true : false ;
71+
72+ if (isset ($ config ['CURLOPT_SSL_VERIFYPEER ' ]))
73+ $ this ->CURLOPT_SSL_VERIFYPEER = $ config ['CURLOPT_SSL_VERIFYPEER ' ] === 'true ' ? true : false ;
74+
75+ if (isset ($ config ['CURLOPT_VERBOSE ' ]))
76+ $ this ->CURLOPT_VERBOSE = $ config ['CURLOPT_VERBOSE ' ] === 'true ' ? true : false ;
7577
76- if (isset ($ options ['LOG_FILE ' ]))
77- $ this ->options ['LOG_FILE ' ] = $ options ['LOG_FILE ' ];
78- if (isset ($ options ['LOG_LEVEL ' ]))
79- $ this ->options ['LOG_LEVEL ' ] = $ this ->convertLogLevel ($ options ['LOG_LEVEL ' ]);
80- }
78+ if (isset ($ config ['LOG_FILE ' ]))
79+ $ this ->LOG_FILE = $ config ['LOG_FILE ' ];
8180
82- // create logger
83- $ log_file = $ options ['LOG_FILE ' ];
84- $ log_level = $ this ->convertLogLevel ($ options ['LOG_LEVEL ' ]);
81+ if (isset ($ config ['LOG_LEVEL ' ]))
82+ $ this ->LOG_LEVEL = $ this ->convertLogLevel ($ config ['LOG_LEVEL ' ]);
8583
84+ // create logger
8685 $ this ->log = new Logger ('JiraClient ' );
87- $ this ->log ->pushHandler (new StreamHandler ($ this ->options [ ' LOG_FILE ' ] ,
88- $ this ->options [ ' LOG_LEVEL ' ] ));
86+ $ this ->log ->pushHandler (new StreamHandler ($ this ->LOG_FILE ,
87+ $ this ->LOG_LEVEL ));
8988
9089 $ this ->http_response = 200 ;
9190 }
@@ -117,14 +116,14 @@ public function exec($context, $post_data = null, $custom_request = null) {
117116
118117 curl_setopt ($ ch , CURLOPT_USERPWD , "$ this ->username : $ this ->password " );
119118
120- curl_setopt ($ ch , CURLOPT_SSL_VERIFYHOST , $ this ->options [ CURLOPT_SSL_VERIFYHOST ] );
121- curl_setopt ($ ch , CURLOPT_SSL_VERIFYPEER , $ this ->options [ CURLOPT_SSL_VERIFYPEER ] );
119+ curl_setopt ($ ch , CURLOPT_SSL_VERIFYHOST , $ this ->CURLOPT_SSL_VERIFYHOST );
120+ curl_setopt ($ ch , CURLOPT_SSL_VERIFYPEER , $ this ->CURLOPT_SSL_VERIFYPEER );
122121
123122 curl_setopt ($ ch , CURLOPT_FOLLOWLOCATION , true );
124123 curl_setopt ($ ch , CURLOPT_HTTPHEADER ,
125124 array ('Accept: */* ' , 'Content-Type: application/json ' ));
126125
127- curl_setopt ($ ch , CURLOPT_VERBOSE , $ this ->options [ CURLOPT_VERBOSE ] );
126+ curl_setopt ($ ch , CURLOPT_VERBOSE , $ this ->CURLOPT_VERBOSE );
128127
129128 $ this ->log ->addDebug ('Curl exec= ' . $ url );
130129 $ response = curl_exec ($ ch );
0 commit comments