Passed
Push — master ( a6a132...f48b58 )
by Pascal
03:05
created

EncodingException   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 28
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 11
dl 0
loc 28
rs 10
c 1
b 0
f 0
wmc 5

4 Methods

Rating   Name   Duplication   Size   Complexity  
A decorate() 0 9 2
A getCommand() 0 3 1
A getAlchemyException() 0 3 1
A getErrorOutput() 0 3 1
1
<?php
2
3
namespace ProtoneMedia\LaravelFFMpeg\Exporters;
4
5
use Alchemy\BinaryDriver\Exception\ExecutionFailureException;
6
use FFMpeg\Exception\RuntimeException;
7
8
class EncodingException extends RuntimeException
9
{
10
    public static function decorate(RuntimeException $runtimeException): EncodingException
11
    {
12
        return tap(new static(
13
            $runtimeException->getMessage(),
14
            $runtimeException->getCode(),
15
            $runtimeException->getPrevious()
16
        ), function (self $exception) {
17
            if (config('laravel-ffmpeg.set_command_and_error_output_on_exception')) {
18
                $exception->message = $exception->getAlchemyException()->getMessage();
19
            }
20
        });
21
    }
22
23
    public function getCommand(): string
24
    {
25
        return $this->getAlchemyException()->getCommand();
26
    }
27
28
    public function getErrorOutput(): string
29
    {
30
        return $this->getAlchemyException()->getErrorOutput();
31
    }
32
33
    public function getAlchemyException(): ExecutionFailureException
34
    {
35
        return $this->getPrevious();
36
    }
37
}
38