GPWebPayResultException   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 37
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 10
c 1
b 0
f 0
dl 0
loc 37
ccs 12
cts 12
cp 1
rs 10
wmc 5

5 Methods

Rating   Name   Duplication   Size   Complexity  
A getSrcode() 0 3 1
A __construct() 0 11 1
A translate() 0 3 1
A getResultText() 0 3 1
A getPrcode() 0 3 1
1
<?php
2
3
/**
4
 * This file is part of the Pixidos package.
5
 *
6
 *  (c) Ondra Votava <[email protected]>
7
 *
8
 *  For the full copyright and license information, please view the LICENSE
9
 *  file that was distributed with this source code.
10
 *
11
 */
12
13
declare(strict_types=1);
14
15
namespace Pixidos\GPWebPay\Exceptions;
16
17
use Pixidos\GPWebPay\Data\ResponseError;
18
use Throwable;
19
20
class GPWebPayResultException extends GPWebPayException
21
{
22
    private string|null $resultText;
23
    private ResponseError $error;
24
25 4
    public function __construct(
26
        string $message,
27
        int $prCode,
28
        int $srCode,
29
        ?string $resultText = null,
30
        int $code = 0,
31
        ?Throwable $previous = null
32
    ) {
33 4
        parent::__construct($message, $code, $previous);
34 4
        $this->resultText = $resultText;
35 4
        $this->error = new ResponseError($prCode, $srCode);
36
    }
37
38 2
    public function getPrcode(): int
39
    {
40 2
        return $this->error->getPrcode();
41
    }
42
43 2
    public function getSrcode(): int
44
    {
45 2
        return $this->error->getSrcode();
46
    }
47
48
49 2
    public function getResultText(): ?string
50
    {
51 2
        return $this->resultText;
52
    }
53
54 1
    public function translate(string $lang): string
55
    {
56 1
        return $this->error->getMessage($lang);
57
    }
58
}
59