Issues (33)

src/Exception/OperationException.php (1 issue)

1
<?php
0 ignored issues
show
Header blocks must be separated by a single blank line
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\OperationInterface;
10
use RuntimeException;
11
use Throwable;
12
13
class OperationException extends RuntimeException implements
14
    OperationExceptionInterface
15
{
16
    /** @var OperationInterface|null */
17
    private $operation;
18
19
    /**
20
     * Constructor.
21
     *
22
     * @param string                  $message
23
     * @param OperationInterface|null $operation
24
     * @param Throwable|null          $previous
25
     */
26 1
    public function __construct(
27
        string $message,
28
        ?OperationInterface $operation,
29
        Throwable $previous = null
30
    ) {
31 1
        $this->operation = $operation;
32 1
        parent::__construct($message, 0, $previous);
33 1
    }
34
35
    /**
36
     * Get the operation that caused the exception to occur.
37
     * Returns null if the operation cannot be determined.
38
     *
39
     * @return OperationInterface|null
40
     */
41 1
    public function getOperation(): ?OperationInterface
42
    {
43 1
        return $this->operation;
44
    }
45
}
46