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

ProxyTrait::getCurrentError()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 1
c 1
b 0
f 0
nc 1
nop 0
dl 0
loc 3
ccs 0
cts 3
cp 0
crap 2
rs 10
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