Vote::send()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 3
c 1
b 0
f 0
nc 1
nop 0
dl 0
loc 6
ccs 0
cts 4
cp 0
crap 2
rs 10
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;
14
15
use D3strukt0r\VotifierClient\ServerType\ServerTypeInterface;
16
use D3strukt0r\VotifierClient\VoteType\VoteInterface;
17
use Exception;
18
19
/**
20
 * This class is used for easy access to all classes and to send the votes.
21
 */
22
class Vote
23
{
24
    /**
25
     * @var VoteInterface the vote package
26
     */
27
    private $vote;
28
29
    /**
30
     * @var ServerTypeInterface the server type information package
31
     */
32
    private $server;
33
34
    /**
35
     * Created a Vote object.
36
     *
37
     * @param VoteInterface       $vote       (Required) The vote package
38
     * @param serverTypeInterface $serverType (Required) The server type information package
39
     */
40 1
    public function __construct(VoteInterface $vote, ServerTypeInterface $serverType)
41
    {
42 1
        $this->vote = $vote;
43 1
        $this->server = $serverType;
44 1
    }
45
46
    /**
47
     * Sends the vote package to the server.
48
     *
49
     * @throws Exception
50
     */
51
    public function send(): void
52
    {
53
        $con = new ServerConnection($this->server);
54
55
        $this->vote->setTimestamp();
56
        $this->server->send($con, $this->vote);
57
    }
58
}
59