GPWebPayResultException::getSrcode()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 1
c 1
b 0
f 0
nc 1
nop 0
dl 0
loc 3
ccs 2
cts 2
cp 1
crap 1
rs 10
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