Passed
Push — master ( 2d5d29...0740c8 )
by ReliQ
04:50 queued 13s
created

AssetPublicationFailed   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 23
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 8
dl 0
loc 23
rs 10
c 0
b 0
f 0
wmc 1

1 Method

Rating   Name   Duplication   Size   Complexity  
A forProductAssetsOfType() 0 11 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace ReliqArts\Docweaver\Exception\Product;
6
7
use ReliqArts\Docweaver\Contract\Exception;
8
use ReliqArts\Docweaver\Model\Product;
9
10
final class AssetPublicationFailed extends PublicationFailed
11
{
12
    private const CODE = 8002;
13
14
    /**
15
     * @var null|string
16
     */
17
    protected ?string $assetType;
18
19
    /**
20
     * AssetPublicationFailed constructor.
21
     */
22
    public static function forProductAssetsOfType(
23
        Product $product,
24
        string $assetType,
25
        Exception $previous = null
26
    ): Exception {
27
        $message = sprintf('Failed to publish %s assets for product `%s`.', $assetType, $product->getName());
28
        $self = new self($message, self::CODE, $previous);
29
        $self->product = $product;
30
        $self->assetType = $assetType;
31
32
        return $self;
33
    }
34
}
35