Skip to content

Commit

Permalink
Merge pull request #4 from BitBagCommerce/OPSRC-496/Add_bitbag_coding…
Browse files Browse the repository at this point in the history
…_standard_to_every_plugin

OPSRC-496/Add bitbag coding standard and ecs fix
  • Loading branch information
fabulousPuppet authored Jul 29, 2022
2 parents fc98112 + bf484d1 commit 7bd5f77
Show file tree
Hide file tree
Showing 9 changed files with 36 additions and 19 deletions.
4 changes: 4 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,10 @@ jobs:
name: Validate database schema
run: (cd tests/Application && bin/console doctrine:schema:validate)

-
name: Run ECS
run: vendor/bin/ecs check src

-
name: Run PHPSpec
run: vendor/bin/phpspec run --ansi -f progress --no-interaction
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
"require-dev": {
"behat/behat": "^3.6.1",
"behat/mink-selenium2-driver": "^1.4",
"bitbag/coding-standard": "^1.0",
"dmore/behat-chrome-extension": "^1.3",
"dmore/chrome-mink-driver": "^2.7",
"friends-of-behat/mink": "^1.8",
Expand All @@ -43,7 +44,6 @@
"phpunit/phpunit": "^9.5",
"polishsymfonycommunity/symfony-mocker-container": "^1.0",
"sensiolabs/security-checker": "^6.0",
"sylius-labs/coding-standard": "^4.0",
"symfony/browser-kit": "^4.4 || ^5.2",
"symfony/debug-bundle": "^4.4 || ^5.2",
"symfony/dotenv": "^4.4 || ^5.2",
Expand Down
16 changes: 16 additions & 0 deletions ecs.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<?php

declare(strict_types=1);

use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
use Symplify\EasyCodingStandard\ValueObject\Option;

return static function (ContainerConfigurator $containerConfigurator): void {
$containerConfigurator->import('vendor/bitbag/coding-standard/ecs.php');

$parameters = $containerConfigurator->parameters();
$parameters->set(Option::PATHS, [
__DIR__ . '/src',
__DIR__ . '/tests',
]);
};
14 changes: 6 additions & 8 deletions src/Api/WebClient.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,14 @@
use BitBag\SyliusPocztaPolskaShippingExportPlugin\Factory\ShipmentFactoryInterface;
use BitBag\SyliusPocztaPolskaShippingExportPlugin\Generator\GuidGeneratorInterface;
use BitBag\SyliusShippingExportPlugin\Entity\ShippingGatewayInterface;
use PocztaPolska\ElektronicznyNadawca;
use PocztaPolska\getAddresLabelByGuidResponse;
use PocztaPolska\getEnvelopeBufor;
use PocztaPolska\getUrzedyNadania;
use PocztaPolska\sendEnvelope;
use SoapFault;
use Sylius\Component\Core\Model\OrderInterface;
use Sylius\Component\Core\Model\ShipmentInterface;
use PocztaPolska\ElektronicznyNadawca;

final class WebClient implements WebClientInterface
{
Expand Down Expand Up @@ -89,7 +89,7 @@ public function createLabel(): getAddresLabelByGuidResponse

public function getLabelContent(): ?string
{
return base64_decode((string)$this->createLabel()->content->pdfContent);
return base64_decode((string) $this->createLabel()->content->pdfContent);
}

/**
Expand All @@ -103,11 +103,11 @@ public function sendEnvelope(): array

$packagesShipped = [];

if(is_array($packages)) {
if (is_array($packages)) {
foreach ($packages as $package) {
$packagesShipped[] = $package->guid;
}
} else if($packages !== null) {
} elseif (null !== $packages) {
$packagesShipped[] = $packages->guid;
} else {
return [];
Expand All @@ -119,11 +119,9 @@ public function sendEnvelope(): array
$sendEnvelope = new sendEnvelope();
$sendEnvelope->urzadNadania = $post->urzadNadania;


$sendEnvelopeResponseType = $this->connection->sendEnvelope($sendEnvelope);


if ($sendEnvelopeResponseType->error === null) {
if (null === $sendEnvelopeResponseType->error) {
return $packagesShipped;
}

Expand All @@ -139,7 +137,7 @@ private function connect(): ElektronicznyNadawca
$this->getShippingGatewayConfig('wsdl'),
[
'login' => $this->getShippingGatewayConfig('login'),
'password' => $this->getShippingGatewayConfig('password')
'password' => $this->getShippingGatewayConfig('password'),
]
);
}
Expand Down
2 changes: 1 addition & 1 deletion src/Api/WebClientInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@
namespace BitBag\SyliusPocztaPolskaShippingExportPlugin\Api;

use BitBag\SyliusShippingExportPlugin\Entity\ShippingGatewayInterface;
use PocztaPolska\getAddresLabelByGuidResponse;
use SoapFault;
use Sylius\Component\Core\Model\ShipmentInterface;
use PocztaPolska\getAddresLabelByGuidResponse;

interface WebClientInterface
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
final class BitBagSyliusPocztaPolskaShippingExportExtension extends Extension
{
/**
* {@inheritdoc}
* @inheritdoc
*/
public function load(array $config, ContainerBuilder $container)
{
Expand All @@ -27,4 +27,3 @@ public function load(array $config, ContainerBuilder $container)
$loader->load('services.yml');
}
}

6 changes: 3 additions & 3 deletions src/Factory/PackageFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,12 @@

use BitBag\SyliusPocztaPolskaShippingExportPlugin\Checker\PaymentCheckerInterface;
use BitBag\SyliusShippingExportPlugin\Entity\ShippingGatewayInterface;
use PocztaPolska\adresType;
use PocztaPolska\gabarytBiznesowaType;
use PocztaPolska\pobranieType;
use PocztaPolska\przesylkaBiznesowaType;
use PocztaPolska\przesylkaPoleconaZagranicznaType;
use PocztaPolska\sposobPobraniaType;
use PocztaPolska\adresType;
use Sylius\Component\Core\Model\ShipmentInterface;

class PackageFactory implements PackageFactoryInterface
Expand All @@ -39,7 +39,7 @@ public function createNew(
): object {
$order = $shipmentInterface->getOrder();

if ($order->getShippingAddress()->getCountryCode() !== self::COUNTRY_CODE) {
if (self::COUNTRY_CODE !== $order->getShippingAddress()->getCountryCode()) {
$package = new przesylkaPoleconaZagranicznaType();
} else {
$package = new PrzesylkaBiznesowaType();
Expand All @@ -56,7 +56,7 @@ public function createNew(
}

$package->adres = $addressType;
if ($order->getShippingAddress()->getCountryCode() !== self::COUNTRY_CODE) {
if (self::COUNTRY_CODE !== $order->getShippingAddress()->getCountryCode()) {
$package->adres->kraj = $order->getShippingAddress()->getCountryCode();
}
$package->gabaryt = gabarytBiznesowaType::M;
Expand Down
3 changes: 1 addition & 2 deletions src/Factory/PackageFactoryInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,7 @@ interface PackageFactoryInterface
{
public function createNew(
AdresType $addressType,
ShippingGatewayInterface
$shippingGateway,
ShippingGatewayInterface $shippingGateway,
string $guid,
ShipmentInterface $shipmentInterface
): object;
Expand Down
5 changes: 3 additions & 2 deletions src/Generator/GuidGenerator.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,9 @@ class GuidGenerator implements GuidGeneratorInterface
{
public function generate(): string
{
mt_srand((int)microtime()*10000);
$charId = strtoupper(md5(uniqid((string)rand(), true)));
mt_srand((int) microtime() * 10000);
$charId = strtoupper(md5(uniqid((string) rand(), true)));

return substr($charId, 0, 32);
}
}

0 comments on commit 7bd5f77

Please sign in to comment.