Test Failed
Pull Request — master (#5)
by Jan-Marten
04:30
created

TransactionRolledBackException::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 15
Code Lines 11

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 8
CRAP Score 1.0202

Importance

Changes 0
Metric Value
cc 1
eloc 11
nc 1
nop 1
dl 0
loc 15
ccs 8
cts 11
cp 0.7272
crap 1.0202
rs 9.9
c 0
b 0
f 0
1
<?php
0 ignored issues
show
introduced by
An error occurred during processing; checking has been aborted. The error message was: implode(): Passing glue string after array is deprecated. Swap the parameters in /home/scrutinizer/build/vendor/squizlabs/php_codesniffer/src/Standards/Squiz/Sniffs/Commenting/FunctionCommentSniff.php on line 468
Loading history...
2
/**
3
 * Copyright MediaCT. All rights reserved.
4
 * https://www.mediact.nl
5
 */
6
7
namespace Johmanx10\Transaction\Exception;
8
9
use Johmanx10\Transaction\OperationFailureInterface;
10
use RuntimeException;
11
12
class TransactionRolledBackException extends RuntimeException implements TransactionRolledBackExceptionInterface
13
{
14
    /** @var OperationFailureInterface[] */
15
    private array $failures;
16
17
    /**
18
     * Constructor.
19
     *
20
     * @param OperationFailureInterface ...$failures
21
     */
22 3
    public function __construct(OperationFailureInterface ...$failures)
23
    {
24 3
        $this->failures = $failures;
25
26 3
        parent::__construct(
27
            sprintf(
28 3
                '%d operations were rolled back: %s',
29 3
                count($failures),
30
                implode(
31 3
                    ', ',
32
                    array_map(
33
                        function (OperationFailureInterface $failure): int {
34 2
                            return spl_object_id($failure->getOperation());
35 3
                        },
36
                        $failures
37
                    )
38
                )
39
            )
40
        );
41 3
    }
42
43
    /**
44
     * Get the failed operations.
45
     *
46
     * @return OperationFailureInterface[]
47
     */
48 3
    public function getFailures(): array
49
    {
50 3
        return $this->failures;
51
    }
52
}
53