PublicationFailed   A
last analyzed

Complexity

Total Complexity 1

Size/Duplication

Total Lines 19
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 7
dl 0
loc 19
rs 10
c 0
b 0
f 0
wmc 1

1 Method

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