Passed
Push — master ( a69d6c...5d5b4c )
by Manuele
04:23 queued 12s
created

Vote   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 35
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 8
c 1
b 0
f 0
dl 0
loc 35
ccs 0
cts 10
cp 0
rs 10
wmc 2

2 Methods

Rating   Name   Duplication   Size   Complexity  
A send() 0 6 1
A __construct() 0 4 1
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
18
/**
19
 * This class is used for easy access to all classes and to send the votes.
20
 */
21
class Vote
22
{
23
    /**
24
     * @var \D3strukt0r\VotifierClient\VoteType\VoteInterface the vote package
25
     */
26
    private $vote;
27
28
    /**
29
     * @var \D3strukt0r\VotifierClient\ServerType\ServerTypeInterface the server type information package
30
     */
31
    private $server;
32
33
    /**
34
     * Created a Vote object.
35
     *
36
     * @param VoteInterface       $vote       (Required) The vote package
37
     * @param serverTypeInterface $serverType (Required) The server type information package
38
     */
39
    public function __construct(VoteInterface $vote, ServerTypeInterface $serverType)
40
    {
41
        $this->vote = $vote;
42
        $this->server = $serverType;
43
    }
44
45
    /**
46
     * Sends the vote package to the server.
47
     *
48
     * @throws \Exception
49
     */
50
    public function send(): void
51
    {
52
        $con = new ServerConnection($this->server);
53
54
        $this->vote->setTimestamp();
55
        $this->server->send($con, $this->vote);
56
    }
57
}
58