Completed
Push — master ( 33e560...941fa0 )
by ReliQ
01:39
created

AssetPublicationFailed   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 25
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

Changes 0
Metric Value
wmc 1
lcom 1
cbo 1
dl 0
loc 25
rs 10
c 0
b 0
f 0
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;
0 ignored issues
show
Bug introduced by
This code did not parse for me. Apparently, there is an error somewhere around this line:

Syntax error, unexpected '?', expecting T_FUNCTION or T_CONST
Loading history...
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