KarmaHandler   A
last analyzed

Complexity

Total Complexity 7

Size/Duplication

Total Lines 39
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 8
c 1
b 0
f 0
dl 0
loc 39
rs 10
wmc 7

5 Methods

Rating   Name   Duplication   Size   Complexity  
A writeUserKarma() 0 2 1
A readUserKarma() 0 2 1
A updateUserKarma() 0 2 1
A calculateUserKarma() 0 9 2
A getUserKarma() 0 5 2
1
<?php
2
3
namespace XoopsModules\Newbb;
4
5
/**
6
 * NewBB 5.0x,  the forum module for XOOPS project
7
 *
8
 * @copyright      XOOPS Project (https://xoops.org)
9
 * @license        GNU GPL 2 or later (https://www.gnu.org/licenses/gpl-2.0.html)
10
 * @author         Taiwen Jiang (phppp or D.J.) <[email protected]>
11
 * @since          4.00
12
 * @package        module::newbb
13
 */
14
class KarmaHandler
15
{
16
    /**
17
     * @param null $user
0 ignored issues
show
Documentation Bug introduced by
Are you sure the doc-type for parameter $user is correct as it would always require null to be passed?
Loading history...
18
     * @return int
19
     */
20
    public function getUserKarma($user = null)
21
    {
22
        $user = (null === $user) ? $GLOBALS['xoopsUser'] : $user;
0 ignored issues
show
introduced by
The condition null === $user is always true.
Loading history...
23
24
        return $this->calculateUserKarma($user);
25
    }
26
27
    /**
28
     * Placeholder for calculating user karma
29
     * @param \XoopsUser $user
30
     * @return int
31
     */
32
    public function calculateUserKarma($user)
33
    {
34
        if (!\is_object($user)) {
35
            $user_karma = 0;
36
        } else {
37
            $user_karma = $user->getVar('posts') * 50;
38
        }
39
40
        return $user_karma;
41
    }
42
43
    public function updateUserKarma()
44
    {
45
    }
46
47
    public function writeUserKarma()
48
    {
49
    }
50
51
    public function readUserKarma()
52
    {
53
    }
54
}
55