@@ -214,23 +214,23 @@ discard block |
||
| 214 | 214 | * @access public |
| 215 | 215 | * @throws \InvalidArgumentException |
| 216 | 216 | */ |
| 217 | - public function __construct( $apiKey = null, $accountType = null ) { |
|
| 218 | - if ( isset( $apiKey ) ) { |
|
| 219 | - if ( is_array( $apiKey ) ) { |
|
| 220 | - if ( isset( $apiKey['api_key'] ) ) { |
|
| 217 | + public function __construct($apiKey = null, $accountType = null) { |
|
| 218 | + if (isset($apiKey)) { |
|
| 219 | + if (is_array($apiKey)) { |
|
| 220 | + if (isset($apiKey['api_key'])) { |
|
| 221 | 221 | $this->apiKey = $apiKey['api_key']; |
| 222 | 222 | } |
| 223 | 223 | |
| 224 | - if ( isset( $apiKey['account_type'] ) ) { |
|
| 224 | + if (isset($apiKey['account_type'])) { |
|
| 225 | 225 | $accountType = $apiKey['account_type']; |
| 226 | 226 | } |
| 227 | - } elseif ( is_string( $apiKey ) ) { |
|
| 227 | + } elseif (is_string($apiKey)) { |
|
| 228 | 228 | $this->apiKey = $apiKey; |
| 229 | 229 | } |
| 230 | 230 | } |
| 231 | 231 | |
| 232 | - if ( isset( $accountType ) ) { |
|
| 233 | - $this->setAccountType( $accountType ); |
|
| 232 | + if (isset($accountType)) { |
|
| 233 | + $this->setAccountType($accountType); |
|
| 234 | 234 | } |
| 235 | 235 | } |
| 236 | 236 | |
@@ -246,7 +246,7 @@ discard block |
||
| 246 | 246 | * @access public |
| 247 | 247 | * @return static |
| 248 | 248 | */ |
| 249 | - public function setApiKey( $apiKey ) { |
|
| 249 | + public function setApiKey($apiKey) { |
|
| 250 | 250 | $this->apiKey = $apiKey; |
| 251 | 251 | |
| 252 | 252 | return $this; |
@@ -265,13 +265,13 @@ discard block |
||
| 265 | 265 | * @return static |
| 266 | 266 | * @throws \InvalidArgumentException |
| 267 | 267 | */ |
| 268 | - public function setAccountType( $accountType ) { |
|
| 269 | - $accountType = strtolower( $accountType ); |
|
| 268 | + public function setAccountType($accountType) { |
|
| 269 | + $accountType = strtolower($accountType); |
|
| 270 | 270 | |
| 271 | - if ( in_array( $accountType, $this->supportedAccountTypes ) ) { |
|
| 271 | + if (in_array($accountType, $this->supportedAccountTypes)) { |
|
| 272 | 272 | $this->accountType = $accountType; |
| 273 | 273 | } else { |
| 274 | - throw new \InvalidArgumentException( 'Rajaongkir: Invalid Account Type' ); |
|
| 274 | + throw new \InvalidArgumentException('Rajaongkir: Invalid Account Type'); |
|
| 275 | 275 | } |
| 276 | 276 | |
| 277 | 277 | return $this; |
@@ -291,10 +291,10 @@ discard block |
||
| 291 | 291 | * @access protected |
| 292 | 292 | * @return array|bool Returns FALSE if failed. |
| 293 | 293 | */ |
| 294 | - protected function request( $path, $params = [], $type = 'GET' ) { |
|
| 294 | + protected function request($path, $params = [], $type = 'GET') { |
|
| 295 | 295 | $apiUrl = 'https://api.rajaongkir.com'; |
| 296 | 296 | |
| 297 | - switch ( $this->accountType ) { |
|
| 297 | + switch ($this->accountType) { |
|
| 298 | 298 | default: |
| 299 | 299 | case 'starter': |
| 300 | 300 | $path = 'starter/' . $path; |
@@ -310,48 +310,48 @@ discard block |
||
| 310 | 310 | break; |
| 311 | 311 | } |
| 312 | 312 | |
| 313 | - $uri = ( new Uri( $apiUrl ) )->withPath( $path ); |
|
| 313 | + $uri = (new Uri($apiUrl))->withPath($path); |
|
| 314 | 314 | $request = new Curl\Request(); |
| 315 | - $request->setHeaders( [ |
|
| 315 | + $request->setHeaders([ |
|
| 316 | 316 | 'key' => $this->apiKey, |
| 317 | - ] ); |
|
| 317 | + ]); |
|
| 318 | 318 | |
| 319 | - switch ( $type ) { |
|
| 319 | + switch ($type) { |
|
| 320 | 320 | default: |
| 321 | 321 | case 'GET': |
| 322 | - $this->response = $request->setUri( $uri )->get( $params ); |
|
| 322 | + $this->response = $request->setUri($uri)->get($params); |
|
| 323 | 323 | break; |
| 324 | 324 | |
| 325 | 325 | case 'POST': |
| 326 | - $request->addHeader( 'content-type', 'application/x-www-form-urlencoded' ); |
|
| 327 | - $this->response = $request->setUri( $uri )->post( $params ); |
|
| 326 | + $request->addHeader('content-type', 'application/x-www-form-urlencoded'); |
|
| 327 | + $this->response = $request->setUri($uri)->post($params); |
|
| 328 | 328 | break; |
| 329 | 329 | } |
| 330 | 330 | |
| 331 | 331 | // Try to get curl error |
| 332 | - if ( false !== ( $error = $this->response->getError() ) ) { |
|
| 333 | - $this->addErrors( $error->getArrayCopy() ); |
|
| 332 | + if (false !== ($error = $this->response->getError())) { |
|
| 333 | + $this->addErrors($error->getArrayCopy()); |
|
| 334 | 334 | } else { |
| 335 | 335 | $body = $this->response->getBody(); |
| 336 | 336 | |
| 337 | - if ( $body instanceof \DOMDocument ) { |
|
| 337 | + if ($body instanceof \DOMDocument) { |
|
| 338 | 338 | $this->errors[404] = 'Page Not Found!'; |
| 339 | 339 | } else { |
| 340 | 340 | $body = $body->rajaongkir; |
| 341 | 341 | $status = $body['status']; |
| 342 | 342 | |
| 343 | - if ( $status['code'] == 200 ) { |
|
| 344 | - if ( isset( $body['results'] ) ) { |
|
| 345 | - if ( count( $body['results'] ) == 1 && isset( $body['results'][0] ) ) { |
|
| 343 | + if ($status['code'] == 200) { |
|
| 344 | + if (isset($body['results'])) { |
|
| 345 | + if (count($body['results']) == 1 && isset($body['results'][0])) { |
|
| 346 | 346 | return $body['results'][0]; |
| 347 | - } elseif ( count( $body['results'] ) ) { |
|
| 347 | + } elseif (count($body['results'])) { |
|
| 348 | 348 | return $body['results']; |
| 349 | 349 | } |
| 350 | - } elseif ( isset( $body['result'] ) ) { |
|
| 350 | + } elseif (isset($body['result'])) { |
|
| 351 | 351 | return $body['result']; |
| 352 | 352 | } |
| 353 | 353 | } else { |
| 354 | - $this->errors[ $status['code'] ] = $status['description']; |
|
| 354 | + $this->errors[$status['code']] = $status['description']; |
|
| 355 | 355 | } |
| 356 | 356 | } |
| 357 | 357 | } |
@@ -384,7 +384,7 @@ discard block |
||
| 384 | 384 | * @return array|bool Returns FALSE if failed. |
| 385 | 385 | */ |
| 386 | 386 | public function getProvinces() { |
| 387 | - return $this->request( 'province' ); |
|
| 387 | + return $this->request('province'); |
|
| 388 | 388 | } |
| 389 | 389 | |
| 390 | 390 | // ------------------------------------------------------------------------ |
@@ -399,8 +399,8 @@ discard block |
||
| 399 | 399 | * @access public |
| 400 | 400 | * @return array|bool Returns FALSE if failed. |
| 401 | 401 | */ |
| 402 | - public function getProvince( $idProvince ) { |
|
| 403 | - return $this->request( 'province', [ 'id' => $idProvince ] ); |
|
| 402 | + public function getProvince($idProvince) { |
|
| 403 | + return $this->request('province', ['id' => $idProvince]); |
|
| 404 | 404 | } |
| 405 | 405 | |
| 406 | 406 | // ------------------------------------------------------------------------ |
@@ -415,14 +415,14 @@ discard block |
||
| 415 | 415 | * @access public |
| 416 | 416 | * @return array|bool Returns FALSE if failed. |
| 417 | 417 | */ |
| 418 | - public function getCities( $idProvince = null ) { |
|
| 418 | + public function getCities($idProvince = null) { |
|
| 419 | 419 | $params = []; |
| 420 | 420 | |
| 421 | - if ( ! is_null( $idProvince ) ) { |
|
| 421 | + if (!is_null($idProvince)) { |
|
| 422 | 422 | $params['province'] = $idProvince; |
| 423 | 423 | } |
| 424 | 424 | |
| 425 | - return $this->request( 'city', $params ); |
|
| 425 | + return $this->request('city', $params); |
|
| 426 | 426 | } |
| 427 | 427 | |
| 428 | 428 | // ------------------------------------------------------------------------ |
@@ -437,8 +437,8 @@ discard block |
||
| 437 | 437 | * @access public |
| 438 | 438 | * @return array|bool Returns FALSE if failed. |
| 439 | 439 | */ |
| 440 | - public function getCity( $idCity ) { |
|
| 441 | - return $this->request( 'city', [ 'id' => $idCity ] ); |
|
| 440 | + public function getCity($idCity) { |
|
| 441 | + return $this->request('city', ['id' => $idCity]); |
|
| 442 | 442 | } |
| 443 | 443 | |
| 444 | 444 | // ------------------------------------------------------------------------ |
@@ -453,18 +453,18 @@ discard block |
||
| 453 | 453 | * @access public |
| 454 | 454 | * @return array|bool Returns FALSE if failed. |
| 455 | 455 | */ |
| 456 | - public function getSubdistricts( $idCity ) { |
|
| 457 | - if ( $this->accountType === 'starter' ) { |
|
| 456 | + public function getSubdistricts($idCity) { |
|
| 457 | + if ($this->accountType === 'starter') { |
|
| 458 | 458 | $this->errors[302] = 'Unsupported Subdistricts Request. Tipe akun starter tidak mendukung hingga tingkat kecamatan.'; |
| 459 | 459 | |
| 460 | 460 | return false; |
| 461 | - } elseif ( $this->accountType === 'basic' ) { |
|
| 461 | + } elseif ($this->accountType === 'basic') { |
|
| 462 | 462 | $this->errors[302] = 'Unsupported Subdistricts Request. Tipe akun basic tidak mendukung hingga tingkat kecamatan.'; |
| 463 | 463 | |
| 464 | 464 | return false; |
| 465 | 465 | } |
| 466 | 466 | |
| 467 | - return $this->request( 'subdistrict', [ 'city' => $idCity ] ); |
|
| 467 | + return $this->request('subdistrict', ['city' => $idCity]); |
|
| 468 | 468 | } |
| 469 | 469 | |
| 470 | 470 | // ------------------------------------------------------------------------ |
@@ -479,18 +479,18 @@ discard block |
||
| 479 | 479 | * @access public |
| 480 | 480 | * @return array|bool Returns FALSE if failed. |
| 481 | 481 | */ |
| 482 | - public function getSubdistrict( $idSubdistrict ) { |
|
| 483 | - if ( $this->accountType === 'starter' ) { |
|
| 482 | + public function getSubdistrict($idSubdistrict) { |
|
| 483 | + if ($this->accountType === 'starter') { |
|
| 484 | 484 | $this->errors[302] = 'Unsupported Subdistricts Request. Tipe akun starter tidak mendukung hingga tingkat kecamatan.'; |
| 485 | 485 | |
| 486 | 486 | return false; |
| 487 | - } elseif ( $this->accountType === 'basic' ) { |
|
| 487 | + } elseif ($this->accountType === 'basic') { |
|
| 488 | 488 | $this->errors[302] = 'Unsupported Subdistricts Request. Tipe akun basic tidak mendukung hingga tingkat kecamatan.'; |
| 489 | 489 | |
| 490 | 490 | return false; |
| 491 | 491 | } |
| 492 | 492 | |
| 493 | - return $this->request( 'subdistrict', [ 'id' => $idSubdistrict ] ); |
|
| 493 | + return $this->request('subdistrict', ['id' => $idSubdistrict]); |
|
| 494 | 494 | } |
| 495 | 495 | |
| 496 | 496 | // ------------------------------------------------------------------------ |
@@ -505,8 +505,8 @@ discard block |
||
| 505 | 505 | * @access public |
| 506 | 506 | * @return array|bool Returns FALSE if failed. |
| 507 | 507 | */ |
| 508 | - public function getInternationalOrigins( $idProvince = null ) { |
|
| 509 | - if ( $this->accountType === 'starter' ) { |
|
| 508 | + public function getInternationalOrigins($idProvince = null) { |
|
| 509 | + if ($this->accountType === 'starter') { |
|
| 510 | 510 | $this->errors[301] = 'Unsupported International Origin Request. Tipe akun starter tidak mendukung tingkat international.'; |
| 511 | 511 | |
| 512 | 512 | return false; |
@@ -514,11 +514,11 @@ discard block |
||
| 514 | 514 | |
| 515 | 515 | $params = []; |
| 516 | 516 | |
| 517 | - if ( isset( $idProvince ) ) { |
|
| 517 | + if (isset($idProvince)) { |
|
| 518 | 518 | $params['province'] = $idProvince; |
| 519 | 519 | } |
| 520 | 520 | |
| 521 | - return $this->request( 'v2/internationalOrigin', $params ); |
|
| 521 | + return $this->request('v2/internationalOrigin', $params); |
|
| 522 | 522 | } |
| 523 | 523 | |
| 524 | 524 | // ------------------------------------------------------------------------ |
@@ -534,22 +534,22 @@ discard block |
||
| 534 | 534 | * @access public |
| 535 | 535 | * @return array|bool Returns FALSE if failed. |
| 536 | 536 | */ |
| 537 | - public function getInternationalOrigin( $idCity = null, $idProvince = null ) { |
|
| 538 | - if ( $this->accountType === 'starter' ) { |
|
| 537 | + public function getInternationalOrigin($idCity = null, $idProvince = null) { |
|
| 538 | + if ($this->accountType === 'starter') { |
|
| 539 | 539 | $this->errors[301] = 'Unsupported International Origin Request. Tipe akun starter tidak mendukung tingkat international.'; |
| 540 | 540 | |
| 541 | 541 | return false; |
| 542 | 542 | } |
| 543 | 543 | |
| 544 | - if ( isset( $idCity ) ) { |
|
| 544 | + if (isset($idCity)) { |
|
| 545 | 545 | $params['id'] = $idCity; |
| 546 | 546 | } |
| 547 | 547 | |
| 548 | - if ( isset( $idProvince ) ) { |
|
| 548 | + if (isset($idProvince)) { |
|
| 549 | 549 | $params['province'] = $idProvince; |
| 550 | 550 | } |
| 551 | 551 | |
| 552 | - return $this->request( 'v2/internationalOrigin', $params ); |
|
| 552 | + return $this->request('v2/internationalOrigin', $params); |
|
| 553 | 553 | } |
| 554 | 554 | |
| 555 | 555 | // ------------------------------------------------------------------------ |
@@ -565,13 +565,13 @@ discard block |
||
| 565 | 565 | * @return array|bool Returns FALSE if failed. |
| 566 | 566 | */ |
| 567 | 567 | public function getInternationalDestinations() { |
| 568 | - if ( $this->accountType === 'starter' ) { |
|
| 568 | + if ($this->accountType === 'starter') { |
|
| 569 | 569 | $this->errors[301] = 'Unsupported International Destination Request. Tipe akun starter tidak mendukung tingkat international.'; |
| 570 | 570 | |
| 571 | 571 | return false; |
| 572 | 572 | } |
| 573 | 573 | |
| 574 | - return $this->request( 'v2/internationalDestination' ); |
|
| 574 | + return $this->request('v2/internationalDestination'); |
|
| 575 | 575 | } |
| 576 | 576 | |
| 577 | 577 | // ------------------------------------------------------------------------ |
@@ -586,8 +586,8 @@ discard block |
||
| 586 | 586 | * @access public |
| 587 | 587 | * @return array|bool Returns FALSE if failed. |
| 588 | 588 | */ |
| 589 | - public function getInternationalDestination( $idCountry = null ) { |
|
| 590 | - if ( $this->accountType === 'starter' ) { |
|
| 589 | + public function getInternationalDestination($idCountry = null) { |
|
| 590 | + if ($this->accountType === 'starter') { |
|
| 591 | 591 | $this->errors[301] = 'Unsupported International Destination Request. Tipe akun starter tidak mendukung tingkat international.'; |
| 592 | 592 | |
| 593 | 593 | return false; |
@@ -595,11 +595,11 @@ discard block |
||
| 595 | 595 | |
| 596 | 596 | $params = []; |
| 597 | 597 | |
| 598 | - if ( isset( $idCountry ) ) { |
|
| 598 | + if (isset($idCountry)) { |
|
| 599 | 599 | $params['id'] = $idCountry; |
| 600 | 600 | } |
| 601 | 601 | |
| 602 | - return $this->request( 'v2/internationalDestination', $params ); |
|
| 602 | + return $this->request('v2/internationalDestination', $params); |
|
| 603 | 603 | } |
| 604 | 604 | |
| 605 | 605 | // ------------------------------------------------------------------------ |
@@ -632,75 +632,75 @@ discard block |
||
| 632 | 632 | * ); |
| 633 | 633 | * |
| 634 | 634 | */ |
| 635 | - public function getCost( array $origin, array $destination, $metrics, $courier ) { |
|
| 636 | - $params['courier'] = strtolower( $courier ); |
|
| 635 | + public function getCost(array $origin, array $destination, $metrics, $courier) { |
|
| 636 | + $params['courier'] = strtolower($courier); |
|
| 637 | 637 | |
| 638 | - $params['originType'] = strtolower( key( $origin ) ); |
|
| 639 | - $params['destinationType'] = strtolower( key( $destination ) ); |
|
| 638 | + $params['originType'] = strtolower(key($origin)); |
|
| 639 | + $params['destinationType'] = strtolower(key($destination)); |
|
| 640 | 640 | |
| 641 | - if ( $params['originType'] !== 'city' ) { |
|
| 641 | + if ($params['originType'] !== 'city') { |
|
| 642 | 642 | $params['originType'] = 'subdistrict'; |
| 643 | 643 | } |
| 644 | 644 | |
| 645 | - if ( ! in_array( $params['destinationType'], [ 'city', 'country' ] ) ) { |
|
| 645 | + if (!in_array($params['destinationType'], ['city', 'country'])) { |
|
| 646 | 646 | $params['destinationType'] = 'subdistrict'; |
| 647 | 647 | } |
| 648 | 648 | |
| 649 | - if ( is_array( $metrics ) ) { |
|
| 650 | - if ( ! isset( $metrics['weight'] ) and |
|
| 651 | - isset( $metrics['length'] ) and |
|
| 652 | - isset( $metrics['width'] ) and |
|
| 653 | - isset( $metrics['height'] ) |
|
| 649 | + if (is_array($metrics)) { |
|
| 650 | + if (!isset($metrics['weight']) and |
|
| 651 | + isset($metrics['length']) and |
|
| 652 | + isset($metrics['width']) and |
|
| 653 | + isset($metrics['height']) |
|
| 654 | 654 | ) { |
| 655 | - $metrics['weight'] = ( ( $metrics['length'] * $metrics['width'] * $metrics['height'] ) / 6000 ) * 1000; |
|
| 656 | - } elseif ( isset( $metrics['weight'] ) and |
|
| 657 | - isset( $metrics['length'] ) and |
|
| 658 | - isset( $metrics['width'] ) and |
|
| 659 | - isset( $metrics['height'] ) |
|
| 655 | + $metrics['weight'] = (($metrics['length'] * $metrics['width'] * $metrics['height']) / 6000) * 1000; |
|
| 656 | + } elseif (isset($metrics['weight']) and |
|
| 657 | + isset($metrics['length']) and |
|
| 658 | + isset($metrics['width']) and |
|
| 659 | + isset($metrics['height']) |
|
| 660 | 660 | ) { |
| 661 | - $weight = ( ( $metrics['length'] * $metrics['width'] * $metrics['height'] ) / 6000 ) * 1000; |
|
| 661 | + $weight = (($metrics['length'] * $metrics['width'] * $metrics['height']) / 6000) * 1000; |
|
| 662 | 662 | |
| 663 | - if ( $weight > $metrics['weight'] ) { |
|
| 663 | + if ($weight > $metrics['weight']) { |
|
| 664 | 664 | $metrics['weight'] = $weight; |
| 665 | 665 | } |
| 666 | 666 | } |
| 667 | 667 | |
| 668 | - foreach ( $metrics as $key => $value ) { |
|
| 669 | - $params[ $key ] = $value; |
|
| 668 | + foreach ($metrics as $key => $value) { |
|
| 669 | + $params[$key] = $value; |
|
| 670 | 670 | } |
| 671 | - } elseif ( is_numeric( $metrics ) ) { |
|
| 671 | + } elseif (is_numeric($metrics)) { |
|
| 672 | 672 | $params['weight'] = $metrics; |
| 673 | 673 | } |
| 674 | 674 | |
| 675 | - switch ( $this->accountType ) { |
|
| 675 | + switch ($this->accountType) { |
|
| 676 | 676 | case 'starter': |
| 677 | 677 | |
| 678 | - if ( $params['destinationType'] === 'country' ) { |
|
| 678 | + if ($params['destinationType'] === 'country') { |
|
| 679 | 679 | $this->errors[301] = 'Unsupported International Destination. Tipe akun starter tidak mendukung pengecekan destinasi international.'; |
| 680 | 680 | |
| 681 | 681 | return false; |
| 682 | - } elseif ( $params['originType'] === 'subdistrict' or $params['destinationType'] === 'subdistrict' ) { |
|
| 682 | + } elseif ($params['originType'] === 'subdistrict' or $params['destinationType'] === 'subdistrict') { |
|
| 683 | 683 | $this->errors[302] = 'Unsupported Subdistrict Origin-Destination. Tipe akun starter tidak mendukung pengecekan ongkos kirim sampai kecamatan.'; |
| 684 | 684 | |
| 685 | 685 | return false; |
| 686 | 686 | } |
| 687 | 687 | |
| 688 | - if ( ! isset( $params['weight'] ) and |
|
| 689 | - isset( $params['length'] ) and |
|
| 690 | - isset( $params['width'] ) and |
|
| 691 | - isset( $params['height'] ) |
|
| 688 | + if (!isset($params['weight']) and |
|
| 689 | + isset($params['length']) and |
|
| 690 | + isset($params['width']) and |
|
| 691 | + isset($params['height']) |
|
| 692 | 692 | ) { |
| 693 | 693 | $this->errors[304] = 'Unsupported Dimension. Tipe akun starter tidak mendukung pengecekan biaya kirim berdasarkan dimensi.'; |
| 694 | 694 | |
| 695 | 695 | return false; |
| 696 | - } elseif ( isset( $params['weight'] ) and $params['weight'] > 30000 ) { |
|
| 696 | + } elseif (isset($params['weight']) and $params['weight'] > 30000) { |
|
| 697 | 697 | $this->errors[305] = 'Unsupported Weight. Tipe akun starter tidak mendukung pengecekan biaya kirim dengan berat lebih dari 30000 gram (30kg).'; |
| 698 | 698 | |
| 699 | 699 | return false; |
| 700 | 700 | } |
| 701 | 701 | |
| 702 | - if ( ! in_array( $params['courier'], $this->supportedCouriers[ $this->accountType ] ) ) { |
|
| 703 | - $this->errors[303] = 'Unsupported Courier. Tipe akun starter tidak mendukung pengecekan biaya kirim dengan kurir ' . $this->couriersList[ $courier ] . '.'; |
|
| 702 | + if (!in_array($params['courier'], $this->supportedCouriers[$this->accountType])) { |
|
| 703 | + $this->errors[303] = 'Unsupported Courier. Tipe akun starter tidak mendukung pengecekan biaya kirim dengan kurir ' . $this->couriersList[$courier] . '.'; |
|
| 704 | 704 | |
| 705 | 705 | return false; |
| 706 | 706 | } |
@@ -709,30 +709,30 @@ discard block |
||
| 709 | 709 | |
| 710 | 710 | case 'basic': |
| 711 | 711 | |
| 712 | - if ( $params['originType'] === 'subdistrict' or $params['destinationType'] === 'subdistrict' ) { |
|
| 712 | + if ($params['originType'] === 'subdistrict' or $params['destinationType'] === 'subdistrict') { |
|
| 713 | 713 | $this->errors[302] = 'Unsupported Subdistrict Origin-Destination. Tipe akun basic tidak mendukung pengecekan ongkos kirim sampai kecamatan.'; |
| 714 | 714 | |
| 715 | 715 | return false; |
| 716 | 716 | } |
| 717 | 717 | |
| 718 | - if ( ! isset( $params['weight'] ) and |
|
| 719 | - isset( $params['length'] ) and |
|
| 720 | - isset( $params['width'] ) and |
|
| 721 | - isset( $params['height'] ) |
|
| 718 | + if (!isset($params['weight']) and |
|
| 719 | + isset($params['length']) and |
|
| 720 | + isset($params['width']) and |
|
| 721 | + isset($params['height']) |
|
| 722 | 722 | ) { |
| 723 | 723 | $this->errors[304] = 'Unsupported Dimension. Tipe akun basic tidak mendukung pengecekan biaya kirim berdasarkan dimensi.'; |
| 724 | 724 | |
| 725 | 725 | return false; |
| 726 | - } elseif ( isset( $params['weight'] ) and $params['weight'] > 30000 ) { |
|
| 726 | + } elseif (isset($params['weight']) and $params['weight'] > 30000) { |
|
| 727 | 727 | $this->errors[305] = 'Unsupported Weight. Tipe akun basic tidak mendukung pengecekan biaya kirim dengan berat lebih dari 30000 gram (30kg).'; |
| 728 | 728 | |
| 729 | 729 | return false; |
| 730 | - } elseif ( isset( $params['weight'] ) and $params['weight'] < 30000 ) { |
|
| 731 | - unset( $params['length'], $params['width'], $params['height'] ); |
|
| 730 | + } elseif (isset($params['weight']) and $params['weight'] < 30000) { |
|
| 731 | + unset($params['length'], $params['width'], $params['height']); |
|
| 732 | 732 | } |
| 733 | 733 | |
| 734 | - if ( ! in_array( $params['courier'], $this->supportedCouriers[ $this->accountType ] ) ) { |
|
| 735 | - $this->errors[303] = 'Unsupported Courier. Tipe akun basic tidak mendukung pengecekan biaya kirim dengan kurir ' . $this->couriersList[ $courier ] . '.'; |
|
| 734 | + if (!in_array($params['courier'], $this->supportedCouriers[$this->accountType])) { |
|
| 735 | + $this->errors[303] = 'Unsupported Courier. Tipe akun basic tidak mendukung pengecekan biaya kirim dengan kurir ' . $this->couriersList[$courier] . '.'; |
|
| 736 | 736 | |
| 737 | 737 | return false; |
| 738 | 738 | } |
@@ -740,12 +740,12 @@ discard block |
||
| 740 | 740 | break; |
| 741 | 741 | } |
| 742 | 742 | |
| 743 | - $params['origin'] = $origin[ key( $origin ) ]; |
|
| 744 | - $params['destination'] = $destination[ key( $destination ) ]; |
|
| 743 | + $params['origin'] = $origin[key($origin)]; |
|
| 744 | + $params['destination'] = $destination[key($destination)]; |
|
| 745 | 745 | |
| 746 | - $path = key( $destination ) === 'country' ? 'internationalCost' : 'cost'; |
|
| 746 | + $path = key($destination) === 'country' ? 'internationalCost' : 'cost'; |
|
| 747 | 747 | |
| 748 | - return $this->request( $path, $params, 'POST' ); |
|
| 748 | + return $this->request($path, $params, 'POST'); |
|
| 749 | 749 | } |
| 750 | 750 | |
| 751 | 751 | // ------------------------------------------------------------------------ |
@@ -761,15 +761,15 @@ discard block |
||
| 761 | 761 | * @access public |
| 762 | 762 | * @return array|bool Returns FALSE if failed. |
| 763 | 763 | */ |
| 764 | - public function getWaybill( $idWaybill, $courier ) { |
|
| 765 | - $courier = strtolower( $courier ); |
|
| 764 | + public function getWaybill($idWaybill, $courier) { |
|
| 765 | + $courier = strtolower($courier); |
|
| 766 | 766 | |
| 767 | - if ( in_array( $courier, $this->supportedWayBills[ $this->accountType ] ) ) { |
|
| 768 | - return $this->request( 'waybill', [ |
|
| 767 | + if (in_array($courier, $this->supportedWayBills[$this->accountType])) { |
|
| 768 | + return $this->request('waybill', [ |
|
| 769 | 769 | 'key' => $this->apiKey, |
| 770 | 770 | 'waybill' => $idWaybill, |
| 771 | 771 | 'courier' => $courier, |
| 772 | - ], 'POST' ); |
|
| 772 | + ], 'POST'); |
|
| 773 | 773 | } |
| 774 | 774 | |
| 775 | 775 | return false; |
@@ -786,8 +786,8 @@ discard block |
||
| 786 | 786 | * @return array|bool Returns FALSE if failed. |
| 787 | 787 | */ |
| 788 | 788 | public function getCurrency() { |
| 789 | - if ( $this->accountType !== 'starter' ) { |
|
| 790 | - return $this->request( 'currency' ); |
|
| 789 | + if ($this->accountType !== 'starter') { |
|
| 790 | + return $this->request('currency'); |
|
| 791 | 791 | } |
| 792 | 792 | |
| 793 | 793 | $this->errors[301] = 'Unsupported Get Currency. Tipe akun starter tidak mendukung pengecekan currency.'; |
@@ -805,8 +805,8 @@ discard block |
||
| 805 | 805 | * @return array|bool Returns FALSE if failed. |
| 806 | 806 | */ |
| 807 | 807 | public function getSupportedCouriers() { |
| 808 | - if ( isset( $this->supportedCouriers[ $this->accountType ] ) ) { |
|
| 809 | - return $this->supportedCouriers[ $this->accountType ]; |
|
| 808 | + if (isset($this->supportedCouriers[$this->accountType])) { |
|
| 809 | + return $this->supportedCouriers[$this->accountType]; |
|
| 810 | 810 | } |
| 811 | 811 | |
| 812 | 812 | return false; |
@@ -822,8 +822,8 @@ discard block |
||
| 822 | 822 | * @return array|bool Returns FALSE if failed. |
| 823 | 823 | */ |
| 824 | 824 | public function getSupportedWayBills() { |
| 825 | - if ( isset( $this->supportedWayBills[ $this->accountType ] ) ) { |
|
| 826 | - return $this->supportedWayBills[ $this->accountType ]; |
|
| 825 | + if (isset($this->supportedWayBills[$this->accountType])) { |
|
| 826 | + return $this->supportedWayBills[$this->accountType]; |
|
| 827 | 827 | } |
| 828 | 828 | |
| 829 | 829 | return false; |