Skip to content

Commit

Permalink
Merge pull request #96 from pagarme/develop
Browse files Browse the repository at this point in the history
  • Loading branch information
RafaMelazzo authored May 25, 2023
2 parents cec3f0e + a50aec0 commit 4cf4a7a
Show file tree
Hide file tree
Showing 60 changed files with 121 additions and 124 deletions.
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "pagarme/ecommerce-module-core",
"description": "Core component for Pagar.me e-commerce platform modules.",
"license": "MIT",
"version": "2.2.0",
"version": "2.2.1",
"authors": [
{
"name":"Open Source Team"
Expand Down
2 changes: 1 addition & 1 deletion integrityDeploy.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

$moduleCoreSetupReflection = new ReflectionClass($concretePlatformCoreSetupClass);
$concreteCoreSetupFilename = $moduleCoreSetupReflection->getFileName();
$concreteDir = explode(DIRECTORY_SEPARATOR, $concreteCoreSetupFilename);
$concreteDir = explode(DIRECTORY_SEPARATOR, $concreteCoreSetupFilename ?? '');
array_pop($concreteDir);
$concreteDir = implode(DIRECTORY_SEPARATOR, $concreteDir);

Expand Down
2 changes: 1 addition & 1 deletion src/Hub/ValueObjects/HubInstallToken.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,6 @@ final class HubInstallToken extends AbstractValidString
{
protected function validateValue($value)
{
return preg_match('/\w{64}$/', $value) === 1;
return preg_match('/\w{64}$/', $value ?? '') === 1;
}
}
2 changes: 1 addition & 1 deletion src/Kernel/Abstractions/AbstractModuleCoreSetup.php
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,7 @@ public static function getModuleConcreteDir()

$moduleCoreSetupReflection = new ReflectionClass($concretePlatformCoreSetupClass);
$concreteCoreSetupFilename = $moduleCoreSetupReflection->getFileName();
$concreteDir = explode(DIRECTORY_SEPARATOR, $concreteCoreSetupFilename);
$concreteDir = explode(DIRECTORY_SEPARATOR, $concreteCoreSetupFilename ?? '');
array_pop($concreteDir);

self::$moduleConcreteDir = implode(DIRECTORY_SEPARATOR, $concreteDir);
Expand Down
4 changes: 2 additions & 2 deletions src/Kernel/Aggregates/Configuration.php
Original file line number Diff line number Diff line change
Expand Up @@ -577,7 +577,7 @@ public function setAntifraudMinAmount($antifraudMinAmount)
$numbers = '/([^0-9])/i';
$replace = '';

$minAmount = preg_replace($numbers, $replace, $antifraudMinAmount);
$minAmount = preg_replace($numbers, $replace, $antifraudMinAmount ?? '');

if ($minAmount < 0) {
throw new InvalidParamException(
Expand Down Expand Up @@ -893,7 +893,7 @@ public function __call($method, $arguments)
{
$methodSplited = explode(
"_",
preg_replace('/(?<=\\w)(?=[A-Z])/',"_$1", $method)
preg_replace('/(?<=\\w)(?=[A-Z])/',"_$1", $method ?? '')
);

$targetObject = $this;
Expand Down
34 changes: 17 additions & 17 deletions src/Kernel/Factories/ChargeFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -126,25 +126,25 @@ private function extractTransactionsFromDbData($dbData)
$transactions = [];
if (isset($dbData['tran_id']) && $dbData['tran_id'] !== null) {
$tranId = explode(',', $dbData['tran_id']);
$tranPagarmeId = explode(',', $dbData['tran_pagarme_id']);
$tranChargeId = explode(',', $dbData['tran_charge_id']);
$tranAmount = explode(',', $dbData['tran_amount']);
$tranPaidAmount = explode(',', $dbData['tran_paid_amount']);
$tranType = explode(',', $dbData['tran_type']);
$tranStatus = explode(',', $dbData['tran_status']);
$tranCreatedAt = explode(',', $dbData['tran_created_at']);

$tranAcquirerNsu = explode(',', $dbData['tran_acquirer_nsu']);
$tranAcquirerTid = explode(',', $dbData['tran_acquirer_tid']);
$tranPagarmeId = explode(',', $dbData['tran_pagarme_id'] ?? '');
$tranChargeId = explode(',', $dbData['tran_charge_id'] ?? '');
$tranAmount = explode(',', $dbData['tran_amount'] ?? '');
$tranPaidAmount = explode(',', $dbData['tran_paid_amount'] ?? '');
$tranType = explode(',', $dbData['tran_type'] ?? '');
$tranStatus = explode(',', $dbData['tran_status'] ?? '');
$tranCreatedAt = explode(',', $dbData['tran_created_at'] ?? '');

$tranAcquirerNsu = explode(',', $dbData['tran_acquirer_nsu'] ?? '');
$tranAcquirerTid = explode(',', $dbData['tran_acquirer_tid'] ?? '');
$tranAcquirerAuthCode = explode(
',',
$dbData['tran_acquirer_auth_code']
);
$tranAcquirerName = explode(',', $dbData['tran_acquirer_name']);
$tranAcquirerMessage = explode(',', $dbData['tran_acquirer_message']);
$tranBoletoUrl = explode(',', $dbData['tran_boleto_url']);
$tranCardData = explode('---', $dbData['tran_card_data']);
$tranData = explode('---', $dbData['tran_data']);
$dbData['tran_acquirer_auth_code'] ?? ''
);
$tranAcquirerName = explode(',', $dbData['tran_acquirer_name'] ?? '');
$tranAcquirerMessage = explode(',', $dbData['tran_acquirer_message'] ?? '');
$tranBoletoUrl = explode(',', $dbData['tran_boleto_url'] ?? '');
$tranCardData = explode('---', $dbData['tran_card_data'] ?? '');
$tranData = explode('---', $dbData['tran_data'] ?? '');

foreach ($tranId as $index => $id) {
$transaction = [
Expand Down
2 changes: 1 addition & 1 deletion src/Kernel/Factories/OrderFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ public function createFromPlatformData(

$order->setPagarmeId(new OrderId($orderId));

$baseStatus = explode('_', $platformOrder->getStatus());
$baseStatus = explode('_', $platformOrder->getStatus() ?? '');
$status = $baseStatus[0];
for ($i = 1; $i < count($baseStatus); $i++) {
$status .= ucfirst(($baseStatus[$i]));
Expand Down
8 changes: 4 additions & 4 deletions src/Kernel/Factories/TransactionFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public function createFromPostData($postData)

$transaction->setPagarmeId(new TransactionId($postData['id']));

$baseStatus = explode('_', $postData['status']);
$baseStatus = explode('_', $postData['status'] ?? '');
$status = $baseStatus[0];
for ($i = 1; $i < count($baseStatus); $i++) {
$status .= ucfirst(($baseStatus[$i]));
Expand All @@ -34,7 +34,7 @@ public function createFromPostData($postData)
}
$transaction->setStatus(TransactionStatus::$status());

$baseType = explode('_', $postData['transaction_type']);
$baseType = explode('_', $postData['transaction_type'] ?? '');
$type = $baseType[0];
for ($i = 1; $i < count($baseType); $i++) {
$type .= ucfirst(($baseType[$i]));
Expand Down Expand Up @@ -142,7 +142,7 @@ public function createFromDbData($dbData)
$transaction->setAcquirerTid($dbData['acquirer_tid']);
$transaction->setAcquirerAuthCode($dbData['acquirer_auth_code']);

$baseStatus = explode('_', $dbData['status']);
$baseStatus = explode('_', $dbData['status'] ?? '');
$status = $baseStatus[0];
for ($i = 1; $i < count($baseStatus); $i++) {
$status .= ucfirst(($baseStatus[$i]));
Expand All @@ -156,7 +156,7 @@ public function createFromDbData($dbData)
}
$transaction->setStatus(TransactionStatus::$status());

$baseType = explode('_', $dbData['type']);
$baseType = explode('_', $dbData['type'] ?? '');
$type = $baseType[0];
for ($i = 1; $i < count($baseType); $i++) {
$type .= ucfirst(($baseType[$i]));
Expand Down
6 changes: 3 additions & 3 deletions src/Kernel/Helper/StringFunctionsHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ final public function removeSpecialCharacters($str)
return preg_replace(
"/[^a-zA-Z ]/",
'',
$str
$str ?? ''
);
}

Expand All @@ -143,7 +143,7 @@ public function cleanStrToDb($str)
return str_replace(
"'",
"`",
strip_tags($str)
strip_tags($str ?? '')
);
}

Expand All @@ -161,7 +161,7 @@ public static function removeLineBreaks($text)
preg_replace(
$pattern,
' ',
$text
$text ?? ''
)
);

Expand Down
6 changes: 3 additions & 3 deletions src/Kernel/Log/BlurData.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ class BlurData
*/
public function getBlurMethod(string $method)
{
return 'blur' . str_replace(' ', '', ucwords(str_replace('_', ' ', $method)));
return 'blur' . str_replace(' ', '', ucwords(str_replace('_', ' ', $method ?? '')));
}

/**
Expand Down Expand Up @@ -94,7 +94,7 @@ public function blurStreet(string $street)
*/
public function blurDocument(string $document)
{
return preg_replace('/\B[^@.]/', '*', $document);
return preg_replace('/\B[^@.]/', '*', $document ?? '');
}

/**
Expand Down Expand Up @@ -176,7 +176,7 @@ public function blurNeighborhood(?string $neighborhood)
public function blurHolderName(?string $holderName)
{
$holderName = $holderName ?? "";
return preg_replace('/^.{8}/', '$1**', $holderName);
return preg_replace('/^.{8}/', '$1**', $holderName ?? '');
}

/**
Expand Down
2 changes: 1 addition & 1 deletion src/Kernel/Repositories/ConfigurationRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ private function removeSpecialCharacters($jsonEncoded)
preg_replace(
$this->pattern,
' ',
$jsonEncoded
$jsonEncoded ?? ''
)
);
}
Expand Down
2 changes: 1 addition & 1 deletion src/Kernel/Services/LocalizationService.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ private function translateDashboard($string)

private function getI18NTableOrDefaultFor($locale)
{
$langClass = str_replace('_', '', $locale);
$langClass = str_replace('_', '', $locale ?? '');
$langClass = strtoupper($langClass);
$langClass = "Pagarme\\Core\\Kernel\\I18N\\$langClass";

Expand Down
2 changes: 1 addition & 1 deletion src/Kernel/Services/MoneyService.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public function removeSeparators($amount)
return str_replace(
['.', ','],
"",
$amount
$amount ?? ''
);
}
}
2 changes: 1 addition & 1 deletion src/Kernel/Services/OrderService.php
Original file line number Diff line number Diff line change
Expand Up @@ -339,7 +339,7 @@ public function createOrderAtPagarme(PlatformOrderInterface $platformOrder)
private function getResponseHandler($response)
{
$responseClass = get_class($response);
$responseClass = explode('\\', $responseClass);
$responseClass = explode('\\', $responseClass ?? '');

$responseClass =
'Pagarme\\Core\\Payment\\Services\\ResponseHandlers\\' .
Expand Down
5 changes: 1 addition & 4 deletions src/Kernel/ValueObjects/Configuration/CardConfig.php
Original file line number Diff line number Diff line change
Expand Up @@ -139,10 +139,7 @@ private function setMaxInstallmentWithoutInterest($maxInstallmentWithoutInterest
new Installment($newMaxInstallmentWithoutInterest, 1, 0);

if ($newMaxInstallmentWithoutInterest > $this->maxInstallment) {
throw new InvalidParamException(
"'Max installment without interest' must be equal or smaller than 'Max Installments'! ",
$maxInstallmentWithoutInterest
);
$newMaxInstallmentWithoutInterest = $this->maxInstallment;
}

$this->maxInstallmentWithoutInterest = $newMaxInstallmentWithoutInterest;
Expand Down
2 changes: 1 addition & 1 deletion src/Kernel/ValueObjects/Id/AccountId.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,6 @@ class AccountId extends AbstractValidString
{
protected function validateValue($value)
{
return preg_match('/^acc_\w{16}$/', $value) === 1;
return preg_match('/^acc_\w{16}$/', $value ?? '') === 1;
}
}
2 changes: 1 addition & 1 deletion src/Kernel/ValueObjects/Id/ChargeId.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,6 @@ class ChargeId extends AbstractValidString
{
protected function validateValue($value)
{
return preg_match('/^ch_\w{16}$/', $value) === 1;
return preg_match('/^ch_\w{16}$/', $value ?? '') === 1;
}
}
2 changes: 1 addition & 1 deletion src/Kernel/ValueObjects/Id/CustomerId.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,6 @@ class CustomerId extends AbstractValidString
{
protected function validateValue($value)
{
return preg_match('/^cus_\w{16}$/', $value) === 1;
return preg_match('/^cus_\w{16}$/', $value ?? '') === 1;
}
}
2 changes: 1 addition & 1 deletion src/Kernel/ValueObjects/Id/CycleId.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,6 @@ class CycleId extends AbstractValidString
{
protected function validateValue($value)
{
return preg_match('/^cycle_\w{16}$/', $value) === 1;
return preg_match('/^cycle_\w{16}$/', $value ?? '') === 1;
}
}
2 changes: 1 addition & 1 deletion src/Kernel/ValueObjects/Id/GUID.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,6 @@ class GUID extends AbstractValidString
{
protected function validateValue($value)
{
return preg_match('/^\w{8}-(\w{4}-){3}\w{12}$/', $value) === 1;
return preg_match('/^\w{8}-(\w{4}-){3}\w{12}$/', $value ?? '') === 1;
}
}
2 changes: 1 addition & 1 deletion src/Kernel/ValueObjects/Id/InvoiceId.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,6 @@ class InvoiceId extends AbstractValidString
{
protected function validateValue($value)
{
return preg_match('/^in_\w{16}$/', $value) === 1;
return preg_match('/^in_\w{16}$/', $value ?? '') === 1;
}
}
2 changes: 1 addition & 1 deletion src/Kernel/ValueObjects/Id/MerchantId.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,6 @@ class MerchantId extends AbstractValidString
{
protected function validateValue($value)
{
return preg_match('/^merch_\w{16}$/', $value) === 1;
return preg_match('/^merch_\w{16}$/', $value ?? '') === 1;
}
}
2 changes: 1 addition & 1 deletion src/Kernel/ValueObjects/Id/OrderId.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,6 @@ public function __construct($orderId)

protected function validateValue($value)
{
return preg_match('/^or_\w{16}$/', $value) === 1;
return preg_match('/^or_\w{16}$/', $value ?? '') === 1;
}
}
4 changes: 2 additions & 2 deletions src/Kernel/ValueObjects/Id/RecipientId.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ class RecipientId extends AbstractValidString
{
protected function validateValue($value)
{
return (preg_match('/^re_\w{25}$/', $value)
|| preg_match('/^rp_\w{16}$/', $value)) === true;
return (preg_match('/^re_\w{25}$/', $value ?? '')
|| preg_match('/^rp_\w{16}$/', $value ?? '')) === true;
}
}
2 changes: 1 addition & 1 deletion src/Kernel/ValueObjects/Id/SubscriptionId.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,6 @@ class SubscriptionId extends AbstractValidString
{
protected function validateValue($value)
{
return preg_match('/^sub_\w{16}$/', $value) === 1;
return preg_match('/^sub_\w{16}$/', $value ?? '') === 1;
}
}
2 changes: 1 addition & 1 deletion src/Kernel/ValueObjects/Id/TransactionId.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,6 @@ class TransactionId extends AbstractValidString
{
protected function validateValue($value)
{
return preg_match('/^tran_\w{16}$/', $value) === 1;
return preg_match('/^tran_\w{16}$/', $value ?? '') === 1;
}
}
2 changes: 1 addition & 1 deletion src/Kernel/ValueObjects/Key/HubAccessTokenKey.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,6 @@ final class HubAccessTokenKey extends AbstractSecretKey
{
protected function validateValue($value)
{
return preg_match('/^\w{64}$/', $value) === 1;
return preg_match('/^\w{64}$/', $value ?? '') === 1;
}
}
2 changes: 1 addition & 1 deletion src/Kernel/ValueObjects/Key/PublicKey.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ final class PublicKey extends AbstractPublicKey implements SensibleDataInterface
{
protected function validateValue($value)
{
return preg_match('/^pk_\w{16}$/', $value) === 1;
return preg_match('/^pk_\w{16}$/', $value ?? '') === 1;
}

/**
Expand Down
2 changes: 1 addition & 1 deletion src/Kernel/ValueObjects/Key/SecretKey.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,6 @@ final class SecretKey extends AbstractSecretKey
{
protected function validateValue($value)
{
return preg_match('/^sk_\w{16}$/', $value) === 1;
return preg_match('/^sk_\w{16}$/', $value ?? '') === 1;
}
}
2 changes: 1 addition & 1 deletion src/Kernel/ValueObjects/Key/TestPublicKey.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,6 @@ final class TestPublicKey extends AbstractPublicKey
{
protected function validateValue($value)
{
return preg_match('/^pk_test_\w{16}$/', $value) === 1;
return preg_match('/^pk_test_\w{16}$/', $value ?? '') === 1;
}
}
2 changes: 1 addition & 1 deletion src/Kernel/ValueObjects/Key/TestSecretKey.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,6 @@ final class TestSecretKey extends AbstractSecretKey
{
protected function validateValue($value)
{
return preg_match('/^sk_test_\w{16}$/', $value) === 1;
return preg_match('/^sk_test_\w{16}$/', $value ?? '') === 1;
}
}
2 changes: 1 addition & 1 deletion src/Kernel/ValueObjects/NumericString.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,6 @@ class NumericString extends AbstractValidString
{
protected function validateValue($value)
{
return preg_match('/^\d*$/', $value) === 1;
return preg_match('/^\d*$/', $value ?? '') === 1;
}
}
Loading

0 comments on commit 4cf4a7a

Please sign in to comment.