Completed
Push — feature/player-elo ( f5ce1b )
by Vladimir
02:36
created

EloModel::changeElo()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 5
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 3
nc 1
nop 1
1
<?php
2
/**
3
 * This file contains functionality relating to database objects that have ELOs
4
 *
5
 * @package    BZiON\Models
6
 * @license    https://github.com/allejo/bzion/blob/master/LICENSE.md GNU General Public License Version 3
7
 */
8
9
abstract class EloModel extends AvatarModel
10
{
11
    protected $elo;
12
13
    /**
14
     * Increase or decrease the ELO of the team
15
     *
16
     * @param int $adjust The value to be added to the current ELO (negative to substract)
17
     */
18
    public function changeElo($adjust)
19
    {
20
        $this->elo += $adjust;
21
        $this->update('elo', $this->elo);
22
    }
23
24
    /**
25
     * Change the ELO of the team
26
     *
27
     * @param int $elo The new team ELO
28
     */
29
    public function setElo($elo)
30
    {
31
        $this->updateProperty($this->elo, 'elo', $elo);
32
    }
33
34
    /**
35
     * Get the current elo of the model
36
     *
37
     * @return int The elo of the model
38
     */
39
    public function getElo()
40
    {
41
        return $this->elo;
42
    }
43
44
}
45