Passed
Push — develop ( d07d22...02265f )
by Manuele
14:21
created

GenericServerType::getPublicKey()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 1
c 1
b 0
f 0
dl 0
loc 3
rs 10
cc 1
nc 1
nop 0
1
<?php
2
3
/**
4
 * Votifier PHP Client
5
 *
6
 * @package   VotifierClient
7
 * @author    Manuele Vaccari <[email protected]>
8
 * @copyright Copyright (c) 2017-2020 Manuele Vaccari <[email protected]>
9
 * @license   https://github.com/D3strukt0r/votifier-client-php/blob/master/LICENSE.txt GNU General Public License v3.0
10
 * @link      https://github.com/D3strukt0r/votifier-client-php
11
 */
12
13
namespace D3strukt0r\VotifierClient\ServerType;
14
15
abstract class GenericServerType implements ServerTypeInterface
16
{
17
    /**
18
     * @var string the domain or ip to connect to Votifier
19
     */
20
    private $host;
21
22
    /**
23
     * @var int the port which votifier uses on the server
24
     */
25
    private $port = 8192;
26
27
    /**
28
     * @var string The public.key which is generated by the plugin.
29
     */
30
    private $publicKey;
31
32
    /**
33
     * {@inheritdoc}
34
     */
35
    public function getHost(): string
36
    {
37
        return $this->host;
38
    }
39
40
    /**
41
     * {@inheritdoc}
42
     */
43
    public function setHost(string $host): self
44
    {
45
        $this->host = $host;
46
47
        return $this;
48
    }
49
50
    /**
51
     * {@inheritdoc}
52
     */
53
    public function getPort(): int
54
    {
55
        return $this->port;
56
    }
57
58
    /**
59
     * {@inheritdoc}
60
     */
61
    public function setPort(int $port)
62
    {
63
        $this->port = $port;
64
65
        return $this;
66
    }
67
68
    /**
69
     * {@inheritdoc}
70
     */
71
    public function getPublicKey(): string
72
    {
73
        return $this->publicKey;
74
    }
75
76
    /**
77
     * {@inheritdoc}
78
     */
79
    public function setPublicKey(string $publicKey): self
80
    {
81
        $publicKey = wordwrap($publicKey, 65, "\n", true);
82
        $publicKey = <<<EOF
83
-----BEGIN PUBLIC KEY-----
84
{$publicKey}
85
-----END PUBLIC KEY-----
86
EOF;
87
        $this->publicKey = $publicKey;
88
89
        return $this;
90
    }
91
}
92