Skip to content

Commit

Permalink
Support symfony 7
Browse files Browse the repository at this point in the history
  • Loading branch information
Wiktor6 committed Oct 1, 2024
1 parent 8074913 commit c1b72f9
Show file tree
Hide file tree
Showing 26 changed files with 182 additions and 476 deletions.
8 changes: 2 additions & 6 deletions .github/workflows/phpunit.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,10 @@ jobs:
strategy:
matrix:
php-version:
- "7.4"
- "8.0"
- "8.1"
- "8.2"
deps:
- "normal"
include:
- deps: "low"
php-version: "7.4"
- "low"

steps:
- name: "Checkout"
Expand Down
4 changes: 1 addition & 3 deletions .github/workflows/static-analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,7 @@ jobs:
strategy:
matrix:
php-version:
- "7.4"
- "8.0"
- "8.1"
- "8.2"

steps:
- name: "Checkout"
Expand Down
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,7 @@
\.php_cs\.cache
.phpunit.result.cache
composer.lock
/.idea
/.phpunit.cache
/.php-cs-fixer.cache

4 changes: 2 additions & 2 deletions .php-cs-fixer.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
'strict_param' => false,
'array_syntax' => ['syntax' => 'short'],
'concat_space' => ['spacing' => 'one'],
'phpdoc_align' => [],
'phpdoc_align' => ['align' => 'left'],
'phpdoc_summary' => false,
'void_return' => false,
'phpdoc_var_without_name' => false,
Expand All @@ -37,4 +37,4 @@
'sort_algorithm' => 'alpha',
],
]
);
);
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public function __construct(
public function pickupPoints(): void
{
/** @var SearchDivisionsResponse $response */
$response = $this->meestClient->request(new SearchDivisions(DivisionTypeEnum::novaPoshtaPoint()));
$response = $this->meestClient->request(new SearchDivisions(DivisionTypeEnum::NovaPoshtaPoint));

/** @var DivisionDTO $division */
foreach ($response->return as $division) {
Expand Down
19 changes: 9 additions & 10 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,19 @@
"type": "symfony-bundle",
"license": "MIT",
"require": {
"php": ">=7.4|^8.0",
"php": "^8.2",
"ext-soap": "*",
"marc-mabe/php-enum": "^3.0|^4.0",
"symfony/http-kernel": "^5.4|^6.0",
"webmozart/assert": "^1.3"
"symfony/http-kernel": "^6.0|^7.0",
"webmozart/assert": "^1.11"
},
"require-dev": {
"roave/security-advisories": "dev-master",
"phpunit/phpunit": "^9.5",
"symfony/phpunit-bridge": "6.1.*",
"phpro/grumphp": "^1.5.0",
"friendsofphp/php-cs-fixer": "^3.4",
"phpstan/phpstan": "^1.4",
"phpstan/phpstan-webmozart-assert": "^1.0"
"phpunit/phpunit": "^10.5",
"symfony/phpunit-bridge": "6.1.*|^7.0",
"phpro/grumphp": "^2.8",
"friendsofphp/php-cs-fixer": "^3.64",
"phpstan/phpstan": "^1.12",
"phpstan/phpstan-webmozart-assert": "^1.2"
},
"autoload": {
"psr-4": {
Expand Down
15 changes: 3 additions & 12 deletions phpunit.xml.dist
Original file line number Diff line number Diff line change
@@ -1,29 +1,20 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="http://schema.phpunit.de/6.1/phpunit.xsd"
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/10.5/phpunit.xsd"
bootstrap="./vendor/autoload.php"
backupGlobals="false"
beStrictAboutCoversAnnotation="true"
beStrictAboutOutputDuringTests="true"
beStrictAboutTestsThatDoNotTestAnything="true"
beStrictAboutTodoAnnotatedTests="true"
colors="true"
convertErrorsToExceptions="true"
convertNoticesToExceptions="true"
convertWarningsToExceptions="true"
verbose="true"
cacheDirectory=".phpunit.cache"
beStrictAboutCoverageMetadata="true"
>
<php>
<ini name="error_reporting" value="-1"/>
</php>

<testsuites>
<testsuite name="Answear Meest Test Suite">
<directory>./tests</directory>
</testsuite>
</testsuites>

<listeners>
<listener class="Symfony\Bridge\PhpUnit\SymfonyTestsListener"/>
</listeners>
</phpunit>
46 changes: 7 additions & 39 deletions src/Enum/DivisionTypeEnum.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,44 +4,12 @@

namespace Answear\MeestBundle\Enum;

use MabeEnum\Enum;

class DivisionTypeEnum extends Enum
enum DivisionTypeEnum: string
{
public const DIVISION_MEEST_EXPRESS = 'DIVISION';
public const COLLECTION_POINT = 'DIVISION_PICKPOINT';
public const PARCEL_LOCKER = 'POSTSTATION';
public const NOVA_POSHTA_POINT = 'MEEST_PARTNER_PICKUP_POINT_NP';
public const UKR_POSHTA_POINT = 'MEEST_PARTNER_PICKUP_POINT_UP';
public const MEEST_PARTNER_PICKUP_POINT = 'MEEST_PARTNER_PICKUP_POINT';

public static function divisionMeestExpress(): self
{
return static::get(static::DIVISION_MEEST_EXPRESS);
}

public static function collectionPoint(): self
{
return static::get(static::COLLECTION_POINT);
}

public static function parcelLocker(): self
{
return static::get(static::PARCEL_LOCKER);
}

public static function novaPoshtaPoint(): self
{
return static::get(static::NOVA_POSHTA_POINT);
}

public static function ukrPoshtaPoint(): self
{
return static::get(static::UKR_POSHTA_POINT);
}

public static function meestPartnerPickupPoint(): self
{
return static::get(static::MEEST_PARTNER_PICKUP_POINT);
}
case DivisionMeestExpress = 'DIVISION';
case CollectionPoint = 'DIVISION_PICKPOINT';
case ParcelLocker = 'POSTSTATION';
case NovaPoshtaPoint = 'MEEST_PARTNER_PICKUP_POINT_NP';
case UkrPoshtaPoint = 'MEEST_PARTNER_PICKUP_POINT_UP';
case MeestPartnerPickupPoint = 'MEEST_PARTNER_PICKUP_POINT';
}
43 changes: 6 additions & 37 deletions src/Enum/RequestEnum.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,42 +4,11 @@

namespace Answear\MeestBundle\Enum;

use MabeEnum\Enum;

class RequestEnum extends Enum
enum RequestEnum: string
{
public const SEARCH_DIVISIONS = 'searchDivisions';

public const GET_API_VERSION = 'getApiVersion';

public const SEARCH_CITY_BY_POST_CODE = 'searchCityByPostCode';

public const SEARCH_CITY = 'searchCity';

public const SEARCH_STREET_BY_NAME_AND_CITY_ID_REF = 'searchStreetByNameAndCityIdRef';

public static function searchDivisions(): self
{
return static::get(static::SEARCH_DIVISIONS);
}

public static function getApiVersion(): self
{
return static::get(static::GET_API_VERSION);
}

public static function searchCityByPostCode(): self
{
return static::get(static::SEARCH_CITY_BY_POST_CODE);
}

public static function searchCity(): self
{
return static::get(static::SEARCH_CITY);
}

public static function searchStreetByNameAndCityIdRef(): self
{
return static::get(static::SEARCH_STREET_BY_NAME_AND_CITY_ID_REF);
}
case SearchDivisions = 'searchDivisions';
case GetApiVersion = 'getApiVersion';
case SearchCityByPostCode = 'searchCityByPostCode';
case SearchCity = 'searchCity';
case SearchStreetByNameAndCityIdRef = 'searchStreetByNameAndCityIdRef';
}
7 changes: 0 additions & 7 deletions src/Enum/ResponseEnum.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,19 +7,12 @@
class ResponseEnum
{
public const SEARCH_DIVISIONS = 'searchDivisionsResponse';

public const GET_API_VERSION = 'getApiVersionResponse';

public const SEARCH_CITY_BY_POST_CODE = 'searchCityByPostCodeResponse';

public const SEARCH_CITY = 'searchCityResponse';

public const SEARCH_STREET_BY_NAME_AND_CITY_ID_REF = 'searchStreetByNameAndCityIdRefResponse';

// inner DTOs
public const DIVISION_DTO = 'divisionApiBean';

public const CITY_DTO = 'cityApiBean';

public const STREET_DTO = 'streetApiBean';
}
2 changes: 1 addition & 1 deletion src/Request/GetApiVersion.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ public function __construct()

public function getEndpoint(): RequestEnum
{
return RequestEnum::getApiVersion();
return RequestEnum::GetApiVersion;
}

public function toArray(): array
Expand Down
12 changes: 3 additions & 9 deletions src/Request/SearchCity.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,21 +6,15 @@

use Answear\MeestBundle\Enum\RequestEnum;

class SearchCity implements RequestInterface
readonly class SearchCity implements RequestInterface
{
/**
* @var string
*/
private $cityName;

public function __construct(string $cityName)
public function __construct(private string $cityName)
{
$this->cityName = $cityName;
}

public function getEndpoint(): RequestEnum
{
return RequestEnum::searchCity();
return RequestEnum::SearchCity;
}

public function toArray(): array
Expand Down
12 changes: 3 additions & 9 deletions src/Request/SearchCityByPostCode.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,23 +7,17 @@
use Answear\MeestBundle\Enum\RequestEnum;
use Webmozart\Assert\Assert;

class SearchCityByPostCode implements RequestInterface
readonly class SearchCityByPostCode implements RequestInterface
{
/**
* @var string
*/
private $postCode;

public function __construct(string $postCode)
public function __construct(public string $postCode)
{
Assert::length($postCode, 5);
Assert::digits($postCode);
$this->postCode = $postCode;
}

public function getEndpoint(): RequestEnum
{
return RequestEnum::searchCityByPostCode();
return RequestEnum::SearchCityByPostCode;
}

public function toArray(): array
Expand Down
24 changes: 7 additions & 17 deletions src/Request/SearchDivisions.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,34 +7,24 @@
use Answear\MeestBundle\Enum\DivisionTypeEnum;
use Answear\MeestBundle\Enum\RequestEnum;

class SearchDivisions implements RequestInterface
readonly class SearchDivisions implements RequestInterface
{
/**
* @var DivisionTypeEnum|null
*/
private $divisionType;

/**
* @var string|null
*/
private $cityId;

public function __construct(?DivisionTypeEnum $divisionType = null, ?string $cityId = null)
{
$this->divisionType = $divisionType;
$this->cityId = $cityId;
public function __construct(
private ?DivisionTypeEnum $divisionType = null,
private ?string $cityId = null,
) {
}

public function getEndpoint(): RequestEnum
{
return RequestEnum::searchDivisions();
return RequestEnum::SearchDivisions;
}

public function toArray(): array
{
return [
'arg0' => $this->cityId,
'arg1' => $this->divisionType ? $this->divisionType->getValue() : null,
'arg1' => $this->divisionType?->value,
];
}
}
22 changes: 6 additions & 16 deletions src/Request/SearchStreetByNameAndCityIdRef.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,27 +6,17 @@

use Answear\MeestBundle\Enum\RequestEnum;

class SearchStreetByNameAndCityIdRef implements RequestInterface
readonly class SearchStreetByNameAndCityIdRef implements RequestInterface
{
/**
* @var string
*/
private $cityId;

/**
* @var string
*/
private $streetName;

public function __construct(string $cityId, string $streetName)
{
$this->cityId = $cityId;
$this->streetName = $streetName;
public function __construct(
private string $cityId,
private string $streetName,
) {
}

public function getEndpoint(): RequestEnum
{
return RequestEnum::searchStreetByNameAndCityIdRef();
return RequestEnum::SearchStreetByNameAndCityIdRef;
}

public function toArray(): array
Expand Down
Loading

0 comments on commit c1b72f9

Please sign in to comment.