Passed
Pull Request — master (#70)
by Pierre-Henry
03:15
created

KarmaHandler::getUserKarma()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 2
nc 2
nop 1
dl 0
loc 5
rs 10
c 0
b 0
f 0
1
<?php namespace XoopsModules\Newbb;
2
3
/**
4
 * NewBB 5.0x,  the forum module for XOOPS project
5
 *
6
 * @copyright      XOOPS Project (https://xoops.org)
7
 * @license        GNU GPL 2 or later (http://www.gnu.org/licenses/gpl-2.0.html)
8
 * @author         Taiwen Jiang (phppp or D.J.) <[email protected]>
9
 * @since          4.00
10
 * @package        module::newbb
11
 */
12
class KarmaHandler
13
{
14
    /**
15
     * @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...
16
     * @return int
17
     */
18
    public function getUserKarma($user = null)
19
    {
20
        $user = (null === $user) ? $GLOBALS['xoopsUser'] : $user;
21
22
        return $this->calculateUserKarma($user);
23
    }
24
25
    /**
26
     * Placeholder for calculating user karma
27
     * @param \XoopsUser $user
0 ignored issues
show
Bug introduced by
The type XoopsUser was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
28
     * @return int
29
     */
30
    public function calculateUserKarma($user)
31
    {
32
        if (!is_object($user)) {
33
            $user_karma = 0;
34
        } else {
35
            $user_karma = $user->getVar('posts') * 50;
36
        }
37
38
        return $user_karma;
39
    }
40
41
    public function updateUserKarma()
42
    {
43
    }
44
45
    public function writeUserKarma()
46
    {
47
    }
48
49
    public function readUserKarma()
50
    {
51
    }
52
}
53