KarmaHandler::writeUserKarma()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 2
Code Lines 0

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 0
nc 1
nop 0
dl 0
loc 2
rs 10
c 0
b 0
f 0
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