Passed
Push — trunk ( 0cbe36...2f2498 )
by Christian
12:47 queued 13s
created

matchException()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 7
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 2
eloc 3
c 1
b 0
f 0
nc 2
nop 1
dl 0
loc 7
rs 10
1
<?php declare(strict_types=1);
2
3
namespace Shopware\Core\Checkout\Shipping\Aggregate\ShippingMethodPrice;
4
5
use Shopware\Core\Checkout\Shipping\ShippingException;
6
use Shopware\Core\Framework\DataAbstractionLayer\Dbal\ExceptionHandlerInterface;
7
use Shopware\Core\Framework\Log\Package;
8
9
#[Package('checkout')]
10
class ShippingMethodPriceExceptionHandler implements ExceptionHandlerInterface
11
{
12
    public function getPriority(): int
13
    {
14
        return ExceptionHandlerInterface::PRIORITY_DEFAULT;
15
    }
16
17
    public function matchException(\Exception $e): ?\Exception
18
    {
19
        if (\preg_match('/SQLSTATE\[23000\]:.*1062 Duplicate.*shipping_method_price.uniq.shipping_method_quantity_start\'/', $e->getMessage())) {
20
            return ShippingException::duplicateShippingMethodPrice($e);
21
        }
22
23
        return null;
24
    }
25
}
26