Skip to content

Commit 22fe3f0

Browse files
authored
feat!: remove src from namespace and deprecated items (#520)
* feat!: remove src from namespace and deprecated items Also bumps php compatibility to > 7.4 * feat!: remove src from namespace and deprecated items * feat!: remove src from namespace and deprecated items * feat!: remove src from namespace and deprecated items * feat!: remove src from namespace and deprecated items * feat!: remove src from namespace and deprecated items * feat!: remove src from namespace and deprecated items * fix: conform more simply to max length in consignment * fix!: update php requirement to min 7.4 or 8.0 * fix: modernize MyParcelCustomsItem.php * chore: update php unit settings * feat: allow unrelated and printerless return * refactor: implement codacy feedback * style: more readable * style: more readable * fix: use correct method * fix: reactivate dhl consignment test * fix: have coverage file created during tests * fix: implement feedback * fix: implement feedback
1 parent 9252d5c commit 22fe3f0

File tree

176 files changed

+1165
-2476
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

176 files changed

+1165
-2476
lines changed

.github/workflows/--test.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ jobs:
3333
if: github.actor != 'dependabot[bot]' && steps.cache-coverage.outputs.cache-hit != 'true'
3434
id: docker
3535
with:
36-
image: ghcr.io/myparcelnl/php-xd:7.1
36+
image: ghcr.io/myparcelnl/php-xd:7.4
3737

3838
- name: 'Install composer dependencies'
3939
if: github.actor != 'dependabot[bot]' && steps.cache-coverage.outputs.cache-hit != 'true'
@@ -51,6 +51,7 @@ jobs:
5151
docker run \
5252
--volume $PWD:/app \
5353
--env CI=${CI} \
54+
--env XDEBUG_MODE=coverage \
5455
--env API_KEY_NL=${{ secrets.API_KEY_NL }} \
5556
--env API_KEY_BE=${{ secrets.API_KEY_BE }} \
5657
${{ steps.docker.outputs.image }} \

.run/Run all tests.run.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
<configuration default="false" name="Run all tests" type="PHPUnitRunConfigurationType" factoryName="PHPUnit">
33
<CommandLine>
44
<PhpTestInterpreterSettings>
5-
<option name="interpreterName" value="php" />
5+
<option name="interpreterName" value="test" />
66
</PhpTestInterpreterSettings>
77
</CommandLine>
88
<TestRunner configuration_file="/app/phpunit.xml" scope="XML" options="--coverage-html coverage" />

.run/Template PHPUnit.run.xml

Lines changed: 0 additions & 11 deletions
This file was deleted.

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ MyParcel PHP SDK
99

1010
## Requirements
1111

12-
- PHP >=7.1
12+
- PHP >=7.4
1313
- Composer
1414

1515
See [installation] for further instructions.

composer.json

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -35,22 +35,21 @@
3535
]
3636
},
3737
"require": {
38-
"php": ">=7.1.0"
38+
"php": "^7.4 || ^8.0"
3939
},
4040
"require-dev": {
4141
"fakerphp/faker": "^v1.16.0",
42-
"phpunit/phpunit": "^7.5.20",
42+
"phpunit/phpunit": "^9.6.22",
4343
"psr/container": "~1.0.0"
4444
},
4545
"autoload": {
4646
"psr-4": {
47-
"MyParcelNL\\Sdk\\src\\": "src",
48-
"MyParcelNL\\Sdk\\": "src"
47+
"MyParcelNL\\Sdk\\": "src/"
4948
}
5049
},
5150
"autoload-dev": {
5251
"psr-4": {
53-
"MyParcelNL\\Sdk\\Test\\": "test"
52+
"MyParcelNL\\Sdk\\Test\\": "test/"
5453
}
5554
}
56-
}
55+
}

docker-compose.yml

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
1-
version: '3.9'
2-
31
# volumes are not in common, because phpstorm doesn't understand it
42
x-common: &common
5-
image: ghcr.io/myparcelnl/php-xd:7.1
3+
image: ghcr.io/myparcelnl/php-xd:7.4
64
init: true
75
env_file:
86
- .env

phpunit.xml

Lines changed: 14 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,16 @@
11
<?xml version="1.0" encoding="UTF-8"?>
2-
<phpunit
3-
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
4-
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/7.5/phpunit.xsd"
5-
colors="true"
6-
cacheResult="true"
7-
executionOrder="depends,defects">
8-
<testsuites>
9-
<testsuite name="Unit">
10-
<directory>test</directory>
11-
</testsuite>
12-
</testsuites>
13-
<filter>
14-
<whitelist>
15-
<directory suffix=".php">./src</directory>
16-
</whitelist>
17-
</filter>
18-
<php>
19-
<env name="TEST" value="true" />
20-
</php>
2+
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.3/phpunit.xsd" colors="true" cacheResult="true" executionOrder="depends,defects">
3+
<coverage>
4+
<include>
5+
<directory suffix=".php">./src</directory>
6+
</include>
7+
</coverage>
8+
<testsuites>
9+
<testsuite name="Unit">
10+
<directory>test</directory>
11+
</testsuite>
12+
</testsuites>
13+
<php>
14+
<env name="TEST" value="true"/>
15+
</php>
2116
</phpunit>

src/Adapter/ConsignmentAdapter.php

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
<?php
22
declare(strict_types=1);
33

4-
namespace MyParcelNL\Sdk\src\Adapter;
4+
namespace MyParcelNL\Sdk\Adapter;
55

6-
use MyParcelNL\Sdk\src\Helper\Utils;
7-
use MyParcelNL\Sdk\src\Model\Consignment\AbstractConsignment;
8-
use MyParcelNL\Sdk\src\Model\Consignment\DropOffPoint;
6+
use MyParcelNL\Sdk\Helper\Utils;
7+
use MyParcelNL\Sdk\Model\Consignment\AbstractConsignment;
8+
use MyParcelNL\Sdk\Model\Consignment\DropOffPoint;
99

1010
class ConsignmentAdapter
1111
{
@@ -20,9 +20,9 @@ class ConsignmentAdapter
2020
* ConsignmentDecode constructor.
2121
*
2222
* @param array $data
23-
* @param \MyParcelNL\Sdk\src\Model\Consignment\AbstractConsignment $consignment
23+
* @param \MyParcelNL\Sdk\Model\Consignment\AbstractConsignment $consignment
2424
*
25-
* @throws \MyParcelNL\Sdk\src\Exception\MissingFieldException
25+
* @throws \MyParcelNL\Sdk\Exception\MissingFieldException
2626
*/
2727
public function __construct(array $data, AbstractConsignment $consignment)
2828
{
@@ -137,7 +137,7 @@ private function setPickup(): self
137137
'pickup_country' => $pickup['cc'] ?? null,
138138
'pickup_location_code' => $pickup['location_code'] ?? null,
139139
'pickup_location_name' => $pickup['location_name'] ?? null,
140-
'pickup_network_id' => $pickup['retail_network_id'] ?? '',
140+
'retail_network_id' => $pickup['retail_network_id'] ?? '',
141141
'pickup_number' => $pickup['number'] ?? null,
142142
'pickup_postal_code' => $pickup['postal_code'] ?? null,
143143
'pickup_street' => $pickup['street'] ?? null,

src/Adapter/DeliveryOptions/AbstractDeliveryOptionsAdapter.php

Lines changed: 7 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
<?php declare(strict_types=1);
22

3-
namespace MyParcelNL\Sdk\src\Adapter\DeliveryOptions;
3+
namespace MyParcelNL\Sdk\Adapter\DeliveryOptions;
44

5-
use MyParcelNL\Sdk\src\Model\Carrier\CarrierFactory;
6-
use MyParcelNL\Sdk\src\Model\Consignment\AbstractConsignment;
5+
use MyParcelNL\Sdk\Model\Carrier\CarrierFactory;
6+
use MyParcelNL\Sdk\Model\Consignment\AbstractConsignment;
77

88
abstract class AbstractDeliveryOptionsAdapter
99
{
@@ -28,12 +28,12 @@ abstract class AbstractDeliveryOptionsAdapter
2828
protected $packageType;
2929

3030
/**
31-
* @var \MyParcelNL\Sdk\src\Adapter\DeliveryOptions\AbstractPickupLocationAdapter
31+
* @var \MyParcelNL\Sdk\Adapter\DeliveryOptions\AbstractPickupLocationAdapter
3232
*/
3333
protected $pickupLocation;
3434

3535
/**
36-
* @var \MyParcelNL\Sdk\src\Adapter\DeliveryOptions\AbstractShipmentOptionsAdapter|null
36+
* @var \MyParcelNL\Sdk\Adapter\DeliveryOptions\AbstractShipmentOptionsAdapter|null
3737
*/
3838
protected $shipmentOptions;
3939

@@ -99,7 +99,7 @@ public function getPackageTypeId(): ?int
9999
}
100100

101101
/**
102-
* @return \MyParcelNL\Sdk\src\Adapter\DeliveryOptions\AbstractPickupLocationAdapter|null
102+
* @return \MyParcelNL\Sdk\Adapter\DeliveryOptions\AbstractPickupLocationAdapter|null
103103
*/
104104
public function getPickupLocation(): ?AbstractPickupLocationAdapter
105105
{
@@ -123,13 +123,7 @@ public function isPickup(): bool
123123
return false;
124124
}
125125

126-
return in_array(
127-
$this->deliveryType,
128-
[
129-
AbstractConsignment::DELIVERY_TYPE_PICKUP_NAME,
130-
AbstractConsignment::DELIVERY_TYPE_PICKUP_EXPRESS_NAME,
131-
]
132-
);
126+
return AbstractConsignment::DELIVERY_TYPE_PICKUP_NAME == $this->deliveryType;
133127
}
134128

135129
/**

src/Adapter/DeliveryOptions/AbstractPickupLocationAdapter.php

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?php declare(strict_types=1);
22

3-
namespace MyParcelNL\Sdk\src\Adapter\DeliveryOptions;
3+
namespace MyParcelNL\Sdk\Adapter\DeliveryOptions;
44

55
class AbstractPickupLocationAdapter
66
{
@@ -60,15 +60,6 @@ public function getLocationCode(): string
6060
return $this->location_code;
6161
}
6262

63-
/**
64-
* @return string|null
65-
* @deprecated Use getRetailNetworkId instead
66-
*/
67-
public function getPickupNetworkId(): string
68-
{
69-
return $this->getRetailNetworkId();
70-
}
71-
7263
/**
7364
* @return string|null
7465
*/

0 commit comments

Comments
 (0)