Passed
Push — trunk ( 5431f0...a5e232 )
by Christian
12:10 queued 15s
created

NewsletterException   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 18
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 10
c 1
b 0
f 0
dl 0
loc 18
rs 10
wmc 2

1 Method

Rating   Name   Duplication   Size   Complexity  
A recipientNotFound() 0 13 2
1
<?php declare(strict_types=1);
2
3
namespace Shopware\Core\Content\Newsletter;
4
5
use Shopware\Core\Content\Newsletter\Exception\NewsletterRecipientNotFoundException;
6
use Shopware\Core\Framework\Feature;
7
use Shopware\Core\Framework\HttpException;
8
use Shopware\Core\Framework\Log\Package;
9
use Symfony\Component\HttpFoundation\Response;
10
11
#[Package('checkout')]
12
class NewsletterException extends HttpException
13
{
14
    public const NEWSLETTER_RECIPIENT_NOT_FOUND_CODE = 'CONTENT__NEWSLETTER_RECIPIENT_NOT_FOUND';
15
16
    public static function recipientNotFound(
17
        string $identifier,
18
        string $value
19
    ): self {
20
        if (!Feature::isActive('v6.6.0.0')) {
21
            return new NewsletterRecipientNotFoundException($identifier, $value);
0 ignored issues
show
Deprecated Code introduced by
The class Shopware\Core\Content\Ne...ipientNotFoundException has been deprecated: tag:v6.6.0 - will be removed, use NewsletterException::recipientNotFound 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 NewsletterRecipientNotFoundException($identifier, $value);
Loading history...
22
        }
23
24
        return new self(
25
            Response::HTTP_BAD_REQUEST,
26
            self::NEWSLETTER_RECIPIENT_NOT_FOUND_CODE,
27
            'The NewsletterRecipient with the identifier "{{ identifier }}" - {{ value }} was not found.',
28
            ['identifier' => $identifier, 'value' => $value]
29
        );
30
    }
31
}
32