Skip to content

Commit

Permalink
fix phpStan, phpMD, CodeStyle
Browse files Browse the repository at this point in the history
  • Loading branch information
mariolorenz committed Aug 29, 2024
1 parent 295e945 commit 3044b19
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 10 deletions.
18 changes: 13 additions & 5 deletions src/Controller/Admin/OrderList.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,10 @@ protected function prepareWhereQuery($whereQuery, $fullQuery)
$oxOrderNr = $connectionProvider->quoteIdentifier("oxorder.oxordernr");
$oxUnzerOrderNr = $connectionProvider->quoteIdentifier("oxorder.oxunzerordernr");
$orderNrValue = $connectionProvider->quote($orderNrSearch);
$query .= " and ($oxOrderNr like $orderNrValue or $oxUnzerOrderNr like $orderNrValue) ";
$orderNrValue = is_string($orderNrValue) ? $orderNrValue : '';
if ($orderNrValue) {
$query .= " and ($oxOrderNr like $orderNrValue or $oxUnzerOrderNr like $orderNrValue) ";
}
}

return $query;
Expand All @@ -71,7 +74,7 @@ protected function prepareWhereQuery($whereQuery, $fullQuery)
*/
protected function prepareOrderListQuery(array $whereQuery, string $filterQuery): string
{
if (is_array($whereQuery) && count($whereQuery)) {
if (count($whereQuery)) {
$myUtilsString = Registry::getUtilsString();
foreach ($whereQuery as $identifierName => $fieldValue) {
//passing oxunzerordernr because it will be combined with oxordernr
Expand All @@ -96,10 +99,15 @@ protected function prepareOrderListQuery(array $whereQuery, string $filterQuery)
$orderNrQuery = [];
foreach ($values as $value) {
$value = $connectionProvider->quote($value);
$orderNrQuery[] = "($oxOrderNr like $value"
. " or $oxUnzerOrderNr like $value)";
$value = is_string($value) ? $value : '';
if ($value) {
$orderNrQuery[] = "($oxOrderNr like $value"
. " or $oxUnzerOrderNr like $value)";
}
}
if ($orderNrQuery) {
$filterQuery .= "and (" . implode(" or ", $orderNrQuery) . ")";
}
$filterQuery .= "and (" . implode(" or ", $orderNrQuery) . ")";

continue;
}
Expand Down
7 changes: 4 additions & 3 deletions src/Service/Transaction.php
Original file line number Diff line number Diff line change
Expand Up @@ -382,16 +382,15 @@ protected function getNewTransactionObject(): TransactionModel

/**
* @param string $paymentid
* @return array|false
* @return array|null
* @throws Exception
* @throws \Doctrine\DBAL\Exception
*/
public function getTransactionDataByPaymentId(string $paymentid): ?array
{
$result = false;
$result = null;

if ($paymentid) {

$queryBuilderFactory = $this->getServiceFromContainer(QueryBuilderFactoryInterface::class);
$queryBuilder = $queryBuilderFactory->create();

Expand Down Expand Up @@ -475,6 +474,7 @@ public function getPaymentIdByOrderId(string $orderid, bool $withoutCancel = fal
$queryResult = $query->setParameters($parameters)->execute();
if ($queryResult instanceof ResultStatement && $queryResult->columnCount()) {
$result = $queryResult->fetchOne();
$result = is_string($result) ? $result : '';
}

return $result;
Expand Down Expand Up @@ -511,6 +511,7 @@ public function getTransactionIdByOrderId(string $orderid): string
$queryResult = $query->setParameters($parameters)->execute();
if ($queryResult instanceof ResultStatement && $queryResult->columnCount()) {
$result = $queryResult->fetchOne();
$result = is_string($result) ? $result : '';
}

return $result;
Expand Down
5 changes: 3 additions & 2 deletions src/Service/UnzerSDKLoader.php
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,7 @@ public function getUnzerSDKbyKey(string $key): Unzer
* @throws UnzerException
* @throws Exception|\Doctrine\DBAL\Exception
* @SuppressWarnings(PHPMD.StaticAccess)
* @SuppressWarnings(PHPMD.CyclomaticComplexity)
*/
public function getUnzerSDKbyPaymentType(string $sPaymentId): Unzer
{
Expand Down Expand Up @@ -150,8 +151,8 @@ public function getUnzerSDKbyPaymentType(string $sPaymentId): Unzer
$currency = '';
$paymentId = '';
if ($row) {
$currency = $row['currency'];
$paymentId = $row['oxpaymenttype'];
$currency = is_string($row['currency']) ? $row['currency'] : '';
$paymentId = is_string($row['oxpaymenttype']) ? $row['oxpaymenttype'] : '';
if ($paymentId === UnzerDefinitions::INVOICE_UNZER_PAYMENT_ID) {
$customerType = 'B2C';
if (!empty($row['oxdelcompany']) || !empty($row['oxbillcompany'])) {
Expand Down

0 comments on commit 3044b19

Please sign in to comment.