Passed
Push — master ( 195aeb...469104 )
by Romain
36s
created

PaymentSettings::setPrivacyUrl()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 7
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 7
ccs 4
cts 4
cp 1
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 4
nc 1
nop 1
crap 1
1
<?php
2
namespace Kerox\Messenger\Model\ProfileSettings;
3
4
use Kerox\Messenger\Helper\ValidatorTrait;
5
6
class PaymentSettings implements \JsonSerializable
7
{
8
9
    use ValidatorTrait;
10
11
    /**
12
     * @var null|string
13
     */
14
    protected $privacyUrl;
15
16
    /**
17
     * @var null|string
18
     */
19
    protected $publicKey;
20
21
    /**
22
     * @var array
23
     */
24
    protected $testUsers = [];
25
26
    /**
27
     * @param string $privacyUrl
28
     * @return \Kerox\Messenger\Model\ProfileSettings\PaymentSettings
29
     */
30 1
    public function setPrivacyUrl(string $privacyUrl): PaymentSettings
31
    {
32 1
        $this->isValidUrl($privacyUrl);
33 1
        $this->privacyUrl = $privacyUrl;
34
35 1
        return $this;
36
    }
37
38
    /**
39
     * @param string $publicKey
40
     * @return \Kerox\Messenger\Model\ProfileSettings\PaymentSettings
41
     */
42 1
    public function setPublicKey(string $publicKey): PaymentSettings
43
    {
44 1
        $this->publicKey = $publicKey;
45
46 1
        return $this;
47
    }
48
49
    /**
50
     * @param int $testUser
51
     * @return \Kerox\Messenger\Model\ProfileSettings\PaymentSettings
52
     */
53 1
    public function addTestUser(int $testUser): PaymentSettings
54
    {
55 1
        $this->testUsers[] = $testUser;
56
57 1
        return $this;
58
    }
59
60
    /**
61
     * @return array
62
     */
63 1
    public function jsonSerialize(): array
64
    {
65
        $json = [
66 1
            'privacy_url' => $this->privacyUrl,
67 1
            'public_key' => $this->publicKey,
68 1
            'test_users' => $this->testUsers,
69
        ];
70
71 1
        return array_filter($json);
72
    }
73
}
74