Passed
Push — trunk ( 617eba...e4f353 )
by Christian
10:12 queued 13s
created

CountryException::countryStateNotFound()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 11
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 2
eloc 7
nc 2
nop 1
dl 0
loc 11
rs 10
c 1
b 0
f 0
1
<?php declare(strict_types=1);
2
3
namespace Shopware\Core\System\Country;
4
5
use Shopware\Core\Framework\Feature;
6
use Shopware\Core\Framework\HttpException;
7
use Shopware\Core\Framework\Log\Package;
8
use Shopware\Core\System\Country\Exception\CountryNotFoundException;
9
use Shopware\Core\System\Country\Exception\CountryStateNotFoundException;
10
use Symfony\Component\HttpFoundation\Response;
11
12
#[Package('customer-order')]
13
class CountryException extends HttpException
14
{
15
    public const COUNTRY_NOT_FOUND = 'CHECKOUT__COUNTRY_NOT_FOUND';
16
    public const COUNTRY_STATE_NOT_FOUND = 'CHECKOUT__COUNTRY_STATE_NOT_FOUND';
17
18
    public static function countryNotFound(string $id): self
19
    {
20
        if (!Feature::isActive('v6.6.0.0')) {
21
            return new CountryNotFoundException($id);
0 ignored issues
show
Deprecated Code introduced by
The class Shopware\Core\System\Cou...ountryNotFoundException has been deprecated: tag:v6.6.0 - reason:remove-exception - will be removed, use CountryException::countryNotFound instead ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-deprecated  annotation

21
            return /** @scrutinizer ignore-deprecated */ new CountryNotFoundException($id);
Loading history...
22
        }
23
24
        return new self(
25
            Response::HTTP_BAD_REQUEST,
26
            self::COUNTRY_NOT_FOUND,
27
            'Country with id "{{ countryId }}" not found.',
28
            ['countryId' => $id]
29
        );
30
    }
31
32
    public static function countryStateNotFound(string $id): self
33
    {
34
        if (!Feature::isActive('v6.6.0.0')) {
35
            return new CountryStateNotFoundException($id);
0 ignored issues
show
Deprecated Code introduced by
The class Shopware\Core\System\Cou...yStateNotFoundException has been deprecated: tag:v6.6.0 - reason:remove-exception - will be removed, use CountryException::countryStateNotFound instead ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-deprecated  annotation

35
            return /** @scrutinizer ignore-deprecated */ new CountryStateNotFoundException($id);
Loading history...
36
        }
37
38
        return new self(
39
            Response::HTTP_BAD_REQUEST,
40
            self::COUNTRY_STATE_NOT_FOUND,
41
            'Country state with id "{{ stateId }}" not found.',
42
            ['stateId' => $id]
43
        );
44
    }
45
}
46