Passed
Push — master ( 65be94...111ef5 )
by Alexander
02:18
created

ProxyTrait   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 24
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 8
c 1
b 0
f 0
dl 0
loc 24
ccs 0
cts 17
cp 0
rs 10
wmc 5

4 Methods

Rating   Name   Duplication   Size   Complexity  
A repeatError() 0 5 1
A getCurrentError() 0 3 1
A getCurrentResultStatus() 0 3 2
A resetCurrentError() 0 3 1
1
<?php
2
3
namespace Yiisoft\Proxy;
4
5
trait ProxyTrait
6
{
7
    private ?object $currentError = null;
8
9
    protected function getCurrentResultStatus(): string
10
    {
11
        return $this->currentError === null ? 'success' : 'failed';
12
    }
13
14
    protected function repeatError(object $error): void
15
    {
16
        $this->currentError = $error;
17
        $errorClass = get_class($error);
18
        throw new $errorClass($error->getMessage());
19
    }
20
21
    protected function resetCurrentError(): void
22
    {
23
        $this->currentError = null;
24
    }
25
26
    protected function getCurrentError(): ?object
27
    {
28
        return $this->currentError;
29
    }
30
}
31