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

PinCodeResponse   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 16
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 3

Test Coverage

Coverage 0%

Importance

Changes 1
Bugs 0 Features 1
Metric Value
wmc 4
c 1
b 0
f 1
lcom 0
cbo 3
dl 0
loc 16
ccs 0
cts 13
cp 0
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 13 4
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