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

PublicationFailed   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 28
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

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

1 Method

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