Completed
Push — pincode_webhooks ( 493908 )
by
unknown
02:10
created

PinCodeResponse::__construct()   A

Complexity

Conditions 4
Paths 3

Size

Total Lines 13
Code Lines 8

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 20

Importance

Changes 1
Bugs 0 Features 1
Metric Value
c 1
b 0
f 1
dl 0
loc 13
ccs 0
cts 13
cp 0
rs 9.2
cc 4
eloc 8
nc 3
nop 1
crap 20
1
<?php
2
3
namespace Xsolla\SDK\Webhook\Response;
4
5
use Xsolla\SDK\API\XsollaClient;
6
use Xsolla\SDK\Exception\Webhook\XsollaWebhookException;
7
use Xsolla\SDK\Webhook\WebhookResponse;
8
9
class PinCodeResponse extends WebhookResponse
10
{
11
    public function __construct($pinCode)
12
    {
13
        if (!is_string($pinCode)) {
14
            throw new XsollaWebhookException(sprintf(
15
                'Pin code should be non-empty string. %s given',
16
                is_object($pinCode) ? get_class($pinCode) : gettype($pinCode)
17
            ));
18
        }
19
        if ('' === $pinCode) {
20
            throw new XsollaWebhookException('Pin code should be non-empty string. Empty string given');
21
        }
22
        parent::__construct(200, XsollaClient::jsonEncode(array('pin_code' => $pinCode)));
23
    }
24
}
25