Skip to content

Commit fddabc2

Browse files
authored
Merge pull request #28 from dpdconnect/1.1.12
1.1.12
2 parents 12cabc0 + 16570c8 commit fddabc2

17 files changed

+39
-35
lines changed

composer.json

+4-3
Original file line numberDiff line numberDiff line change
@@ -26,14 +26,15 @@
2626
},
2727
"require": {
2828
"php": "^5.5 || ^7.0 || ^8.0",
29-
"ext-json": "*"
29+
"ext-json": "*",
30+
"ext-curl": "*"
3031
},
3132
"require-dev": {
32-
"phpunit/phpunit": "~6.5.0",
3333
"symfony/yaml": "^4.2",
3434
"donatj/mock-webserver": "^2.0",
3535
"overtrue/phplint": "^1.1",
36-
"squizlabs/php_codesniffer": "^3.0@dev"
36+
"squizlabs/php_codesniffer": "^3.0@dev",
37+
"phpunit/phpunit": "^8.5"
3738
},
3839
"config": {
3940
"bin-dir": "bin"

src/CacheWrapper.php

+4-4
Original file line numberDiff line numberDiff line change
@@ -28,13 +28,13 @@ public function getCachedList($key, $previous = false, $prefix = 'dpd')
2828
// This is an hour
2929
$maxAge = 3600;
3030

31-
if($previous) {
31+
if ($previous) {
3232
// This is a year;
3333
$maxAge = 31556926;
3434
}
3535

3636
// Check if implementation supports own caching
37-
if($this->cache instanceof CacheInterface) {
37+
if ($this->cache instanceof CacheInterface) {
3838
return $this->cache->getCache($prefix .sha1(serialize($key)) . ($previous ? '_prev': ''));
3939
}
4040

@@ -61,7 +61,7 @@ public function storeCachedList($data, $key, $prefix = 'dpd')
6161
$year = 31556926;
6262

6363
// Check if implementation supports own caching
64-
if($this->cache instanceof CacheInterface) {
64+
if ($this->cache instanceof CacheInterface) {
6565
$this->cache->setCache($prefix. sha1(serialize($key)), $data, $hour);
6666
$this->cache->setCache($prefix .sha1(serialize($key)). '_prev', $data, $year);
6767

@@ -76,4 +76,4 @@ public function storeCachedList($data, $key, $prefix = 'dpd')
7676
$filename = sys_get_temp_dir().'/dpd/'.sha1($prefix.date('Ymd').serialize($key));
7777
file_put_contents($filename, serialize($data));
7878
}
79-
}
79+
}

src/Client.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ class Client
2424
{
2525
const ENDPOINT = 'https://api.dpdconnect.nl';
2626

27-
const CLIENT_VERSION = '1.0.4';
27+
const CLIENT_VERSION = '1.0.5';
2828

2929
/**
3030
* @var string
@@ -177,7 +177,7 @@ public function getToken()
177177
public function setCacheCallable($cache)
178178
{
179179
foreach ($this as $prop) {
180-
if($prop instanceof CacheableInterface) {
180+
if ($prop instanceof CacheableInterface) {
181181
$prop->setCacheWrapper(new CacheWrapper($cache));
182182
}
183183
}

src/ClientBuilder.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ class ClientBuilder implements ClientBuilderInterface
2626
protected $httpClient;
2727

2828
/**
29-
* @var array meta
29+
* @var array
3030
*/
3131
private $meta;
3232

src/ClientBuilderInterface.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,4 @@
99
*/
1010
interface ClientBuilderInterface
1111
{
12-
}
12+
}

src/Common/AuthenticatedHttpClient.php

-2
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,6 @@ public function sendRequest($httpMethod, $resourceName, array $query = [], array
6666

6767
$response = $this->basicHttpClient->sendRequest($httpMethod, $resourceName, $query, $headers, $body);
6868
} catch (AuthenticateException $e) {
69-
7069
try {
7170
$token = $this->authenticationResource->authenticateByPassword(
7271
$this->authentication->getUsername(),
@@ -89,7 +88,6 @@ public function sendRequest($httpMethod, $resourceName, array $query = [], array
8988
} catch (AuthenticateException $exception) {
9089
$response = [];
9190
}
92-
9391
}
9492

9593
return $response;

src/Common/HttpClient.php

+13-4
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ public function setAuthentication(Authentication $authentication)
141141
*/
142142
public function getRequestUrl($resourceName, $query)
143143
{
144-
if ($this->endpoint == NULL || $this->endpoint == "") {
144+
if ($this->endpoint == null || $this->endpoint == "") {
145145
$this->endpoint = Client::ENDPOINT;
146146
}
147147

@@ -271,13 +271,22 @@ public function sendRequest($method, $resourceName, $query = null, $headers = []
271271
/**
272272
* @return string
273273
*/
274-
private function getPhpVersion()
274+
public function getPhpVersion()
275275
{
276276
if (!defined('PHP_VERSION_ID')) {
277-
$version = explode('.', PHP_VERSION);
278-
define('PHP_VERSION_ID', $version[0] * 10000 + $version[1] * 100 + $version[2]);
277+
define('PHP_VERSION_ID', $this->buildPhpVersion());
279278
}
280279

281280
return 'PHP/'.PHP_VERSION_ID;
282281
}
282+
283+
public function buildPhpVersion()
284+
{
285+
$version = explode('.', PHP_VERSION);
286+
$major = (int)$version[0];
287+
$minor = (int)$version[1];
288+
$patch = (int)$version[2];
289+
290+
return $major * 10000 + $minor * 100 + $patch;
291+
}
283292
}

src/Common/ResourceClientInterface.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ public function createResource($query = [], $body = []);
4040
/**
4141
* Deletes a resource.
4242
*
43-
* @param array $uriParameters URI parameters of the resource
43+
* @param array $query URI parameters of the resource
4444
*
4545
* @return int Status code 204 indicating that the resource has been well deleted
4646
*/

src/Exceptions/DpdException.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
class DpdException extends Exception
1414
{
1515
/**
16-
* @var
16+
* @var mixed
1717
*/
1818
private $errorDetails;
1919

@@ -43,4 +43,4 @@ public function getErrorDetails()
4343
{
4444
return $this->errorDetails;
4545
}
46-
}
46+
}

src/Objects/BaseObject.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ public function jsonSerialize()
5252
$properties = get_object_vars($this);
5353
$properties = array_filter($properties, static function ($value) {
5454
return $value === false || !empty($value);
55-
});
55+
});
5656

5757
return $properties;
5858
}

src/Objects/MetaData.php

+3-3
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ public function getWebshopType()
3737
/**
3838
* @param string $webshopType
3939
*
40-
* @return Metadata
40+
* @return MetaData
4141
*/
4242
public function setWebshopType($webshopType)
4343
{
@@ -57,7 +57,7 @@ public function getWebshopVersion()
5757
/**
5858
* @param string $webshopVersion
5959
*
60-
* @return Metadata
60+
* @return MetaData
6161
*/
6262
public function setWebshopVersion($webshopVersion)
6363
{
@@ -77,7 +77,7 @@ public function getPluginVersion()
7777
/**
7878
* @param string $pluginVersion
7979
*
80-
* @return Metadata
80+
* @return MetaData
8181
*/
8282
public function setPluginVersion($pluginVersion)
8383
{

src/Resources/Authentication.php

+3-5
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,8 @@ class Authentication implements AuthenticationResourceInterface
1818
{
1919
const RESOURCE_URI_AUTH = 'auth/login';
2020

21-
/**
22-
* @param HttpClient $HttpClient
23-
*/
21+
private $httpClient;
22+
2423
public function __construct($httpClient)
2524
{
2625
$this->httpClient = $httpClient;
@@ -63,10 +62,9 @@ protected function authenticate($requestBody)
6362
json_encode($requestBody)
6463
);
6564
return $this->processRequest($response);
66-
}catch (\Exception $exception){
65+
} catch (\Exception $exception) {
6766
return [];
6867
}
69-
7068
}
7169

7270
/**

src/Resources/BaseResource.php

+1-2
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,7 @@ class BaseResource implements CacheableInterface
3636
*/
3737
public function __construct(
3838
$resourceClient
39-
)
40-
{
39+
) {
4140
$this->resourceClient = $resourceClient;
4241
}
4342

src/Resources/CacheInterface.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,4 +17,4 @@ public function setCache($key, $data, $expire);
1717
* @return mixed
1818
*/
1919
public function getCache($key);
20-
}
20+
}

src/Resources/CacheableInterface.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,4 @@ interface CacheableInterface
1010
* @param CacheWrapper $cacheWrapper
1111
*/
1212
public function setCacheWrapper($cacheWrapper);
13-
}
13+
}

src/Resources/Parcel.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
class Parcel extends BaseResource
1313
{
1414
/**
15-
* @param array $query
15+
* @param mixed $id
1616
*
1717
* @return array
1818
* @throws DpdException

src/Resources/Shipment.php

-1
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@ protected function getUrl($async = false)
3030
}
3131

3232
return 'api/connect/v1/shipment';
33-
3433
}
3534

3635
/**

0 commit comments

Comments
 (0)