InconsistentCurrenciesError   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 29
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
dl 0
loc 29
c 0
b 0
f 0
wmc 3
lcom 1
cbo 0
ccs 10
cts 10
cp 1
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 13 2
A getInconsistentCurrencyTypes() 0 4 1
1
<?php
2
3
namespace Adsmurai\Currency\Errors;
4
5
use Adsmurai\Currency\Contracts\CurrencyError;
6
use Adsmurai\Currency\Contracts\Currency;
7
use LogicException;
8
9
final class InconsistentCurrenciesError extends LogicException implements CurrencyError
10
{
11
    /** @var Currency */
12
    private $ct1;
13
    /** @var Currency */
14
    private $ct2;
15
16 2
    public function __construct(Currency $ct1, Currency $ct2)
17
    {
18 2
        $this->ct1 = $ct1;
19 2
        $this->ct2 = $ct2;
20
21 2
        if ($ct1 === $ct2) {
22 1
            throw new LogicException(
23 1
                'Trying to construct InconsistentCurrencyTypesError with exactly equal CurrencyType instances'
24
            );
25
        }
26
27 1
        parent::__construct('Same ISO currency code but different currency settings', 0, null);
28 1
    }
29
30
    /**
31
     * @return Currency[]
32
     */
33 1
    public function getInconsistentCurrencyTypes(): array
34
    {
35 1
        return [$this->ct1, $this->ct2];
36
    }
37
}
38