Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Short array syntax #15

Closed
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
18 changes: 9 additions & 9 deletions src/Pakkelabels.php
Expand Up @@ -108,7 +108,7 @@ public function labels($params){
return $result;
}

private function _make_api_call($path, $method = 'GET',$params = array()){
private function _make_api_call($path, $method = 'GET',$params = []){
$ch = curl_init();
curl_setopt($ch, CURLOPT_USERPWD, $this->_api_user . ":" . $this->_api_key);
$params['user_agent'] = 'pdk_php_library v' . self::VERSION;
Expand All @@ -123,19 +123,19 @@ private function _make_api_call($path, $method = 'GET',$params = array()){
curl_setopt($ch, CURLOPT_URL, $this->_api_base_path . '/' . $path);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $query);
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
curl_setopt($ch, CURLOPT_HTTPHEADER, [
'Content-Type: application/json',
'Content-Length: ' . strlen($query))
'Content-Length: ' . strlen($query)]
);
break;
case 'PUT':
$query = json_encode($params);
curl_setopt($ch, CURLOPT_URL, $this->_api_base_path . '/' . $path);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'PUT');
curl_setopt($ch, CURLOPT_POSTFIELDS, $query);
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
curl_setopt($ch, CURLOPT_HTTPHEADER, [
'Content-Type: application/json',
'Content-Length: ' . strlen($query))
'Content-Length: ' . strlen($query)]
);
break;
case 'DELETE':
Expand Down Expand Up @@ -178,18 +178,18 @@ function($curl, $header) use (&$headers)

$pagination = $this->_extract_pagination($headers);

$output = array(
$output = [
'output' => $output,
'pagination' => $pagination
);
];

return $output;
}

private function _extract_pagination($headers) {

$arr = array('x-per-page', 'x-current-page', 'x-total-count', 'x-total-pages');
$pagination = array();
$arr = ['x-per-page', 'x-current-page', 'x-total-count', 'x-total-pages'];
$pagination = [];
foreach ($arr as &$key) {
if (array_key_exists($key, $headers)) {
$pagination[$key] = $headers[$key][0];
Expand Down