Completed
Push — master ( 3fdc21...2574b5 )
by ReliQ
01:51
created

AssetPublicationFailed   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 31
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

Changes 0
Metric Value
wmc 1
lcom 1
cbo 2
dl 0
loc 31
rs 10
c 0
b 0
f 0

1 Method

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