Completed
Push — master ( b9260b...b1a7da )
by Joachim
06:19
created

getConversionContext()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 1
dl 0
loc 3
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 0
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Setono\SyliusStockMovementPlugin\Exception;
6
7
use RuntimeException;
8
use Safe\Exceptions\StringsException;
9
use function Safe\sprintf;
10
11
final class CurrencyConversionException extends RuntimeException
12
{
13
    /** @var int */
14
    private $amount;
15
16
    /** @var string */
17
    private $sourceCurrency;
18
19
    /** @var string */
20
    private $targetCurrency;
21
22
    /** @var array */
23
    private $conversionContext;
24
25
    /**
26
     * @throws StringsException
27
     */
28
    public function __construct(int $amount, string $sourceCurrency, string $targetCurrency, array $conversionContext = [])
29
    {
30
        parent::__construct(sprintf('The source, %s %d, could not be converted to %s', $sourceCurrency, $amount, $targetCurrency));
31
32
        $this->amount = $amount;
33
        $this->sourceCurrency = $sourceCurrency;
34
        $this->targetCurrency = $targetCurrency;
35
        $this->conversionContext = $conversionContext;
36
    }
37
38
    public function getAmount(): int
39
    {
40
        return $this->amount;
41
    }
42
43
    public function getSourceCurrency(): string
44
    {
45
        return $this->sourceCurrency;
46
    }
47
48
    public function getTargetCurrency(): string
49
    {
50
        return $this->targetCurrency;
51
    }
52
53
    public function getConversionContext(): array
54
    {
55
        return $this->conversionContext;
56
    }
57
}
58