Vote   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 35
Duplicated Lines 0 %

Test Coverage

Coverage 50%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 8
c 1
b 0
f 0
dl 0
loc 35
ccs 4
cts 8
cp 0.5
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
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