PaymentSettings::setPublicKey()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 6

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 6
ccs 3
cts 3
cp 1
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 1
crap 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Kerox\Messenger\Model\ProfileSettings;
6
7
use Kerox\Messenger\Helper\ValidatorTrait;
8
9
/**
10
 * @deprecated Since version 3.3.0 and will be removed in version 4.0.0.
11
 */
12
class PaymentSettings implements \JsonSerializable
13
{
14
    use ValidatorTrait;
15
16
    /**
17
     * @var string|null
18
     */
19
    protected $privacyUrl;
20
21
    /**
22
     * @var string|null
23
     */
24
    protected $publicKey;
25
26
    /**
27
     * @var array
28
     */
29
    protected $testUsers = [];
30
31
    /**
32
     * @return \Kerox\Messenger\Model\ProfileSettings\PaymentSettings
33
     */
34 1
    public static function create(): self
35
    {
36 1
        return new self();
0 ignored issues
show
Deprecated Code introduced by
The class Kerox\Messenger\Model\Pr...ettings\PaymentSettings has been deprecated with message: Since version 3.3.0 and will be removed in version 4.0.0.

This class, trait or interface has been deprecated. The supplier of the file has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the type will be removed from the class and what other constant to use instead.

Loading history...
37
    }
38
39
    /**
40
     * @throws \Kerox\Messenger\Exception\MessengerException
41
     *
42
     * @return \Kerox\Messenger\Model\ProfileSettings\PaymentSettings
43
     */
44 1
    public function setPrivacyUrl(string $privacyUrl): self
45
    {
46 1
        $this->isValidUrl($privacyUrl);
47 1
        $this->privacyUrl = $privacyUrl;
48
49 1
        return $this;
50
    }
51
52
    /**
53
     * @return \Kerox\Messenger\Model\ProfileSettings\PaymentSettings
54
     */
55 1
    public function setPublicKey(string $publicKey): self
56
    {
57 1
        $this->publicKey = $publicKey;
58
59 1
        return $this;
60
    }
61
62
    /**
63
     * @return \Kerox\Messenger\Model\ProfileSettings\PaymentSettings
64
     */
65 1
    public function addTestUser(int $testUser): self
66
    {
67 1
        $this->testUsers[] = $testUser;
68
69 1
        return $this;
70
    }
71
72 1
    public function toArray(): array
73
    {
74
        $array = [
75 1
            'privacy_url' => $this->privacyUrl,
76 1
            'public_key' => $this->publicKey,
77 1
            'test_users' => $this->testUsers,
78
        ];
79
80 1
        return array_filter($array);
81
    }
82
83 1
    public function jsonSerialize(): array
84
    {
85 1
        return $this->toArray();
86
    }
87
}
88