ErrorTrait::__toError()   A
last analyzed

Complexity

Conditions 5
Paths 4

Size

Total Lines 16
Code Lines 8

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 30

Importance

Changes 0
Metric Value
cc 5
eloc 8
nc 4
nop 0
dl 0
loc 16
ccs 0
cts 9
cp 0
crap 30
rs 9.6111
c 0
b 0
f 0
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Cycle\ORM\Command\Traits;
6
7
/**
8
 * Describes why command has been locked up
9
 *
10
 * @internal
11
 */
12
trait ErrorTrait
13
{
14
    public function __toError()
15
    {
16
        $missing = [];
17
        if (\property_exists($this, 'waitScope')) {
18
            foreach ($this->waitScope ?? [] as $name => $n) {
19
                $missing[] = "scope:{$name}";
20
            }
21
        }
22
23
        if (\property_exists($this, 'waitContext')) {
24
            foreach ($this->waitContext ?? [] as $name => $n) {
25
                $missing[] = "{$name}";
26
            }
27
        }
28
29
        return \sprintf('%s(%s)', $this::class, \implode(', ', $missing));
30
    }
31
}
32