Completed
Push — master ( 5fac45...a8bd3e )
by Michael
02:57
created

Helper   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 55
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Importance

Changes 0
Metric Value
dl 0
loc 55
rs 10
c 0
b 0
f 0
wmc 6
lcom 0
cbo 0

4 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 5 1
A getInstance() 0 9 2
A setConfig() 0 10 2
A getDirname() 0 4 1
1
<?php namespace Xoopsmodules\newbb;
2
3
/*
4
     You may not change or alter any portion of this comment or credits
5
     of supporting developers from this source code or any supporting source code
6
     which is considered copyrighted (c) material of the original comment or credit authors.
7
8
     This program is distributed in the hope that it will be useful,
9
     but WITHOUT ANY WARRANTY; without even the implied warranty of
10
     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
11
    */
12
/**
13
 * NewBB module for xoops
14
 *
15
 * @copyright       XOOPS Project (https://xoops.org)
16
 * @license         GPL 2.0 or later
17
 * @package         newbb
18
 * @since           5.0.0
19
 * @author          XOOPS Development Team <[email protected]> - <https://xoops.org>
20
 */
21
22
//defined('XOOPS_ROOT_PATH') || die('Restricted access');
0 ignored issues
show
Unused Code Comprehensibility introduced by
75% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
23
24
/**
25
 * Class Helper
26
 */
27
class Helper extends \Xmf\Module\Helper
28
{
29
    public $debug;
30
31
    /**
32
     * @internal param $debug
33
     * @param bool $debug
34
     */
35
    protected function __construct($debug = false)
36
    {
37
        $this->debug   = $debug;
38
        $this->dirname = basename(dirname(__DIR__));
39
    }
40
41
    /**
42
     * @param bool $debug
43
     *
44
     * @return \Helper
0 ignored issues
show
Documentation introduced by
Consider making the return type a bit more specific; maybe use Helper.

This check looks for the generic type array as a return type and suggests a more specific type. This type is inferred from the actual code.

Loading history...
45
     */
46
    public static function getInstance($debug = false)
47
    {
48
        static $instance;
49
        if (null === $instance) {
50
            $instance = new static($debug);
51
        }
52
53
        return $instance;
54
    }
55
56
57
    /**
58
     * @param null|string $name
59
     * @param null|string $value
60
     *
61
     * @return mixed
0 ignored issues
show
Documentation introduced by
Consider making the return type a bit more specific; maybe use null|string.

This check looks for the generic type array as a return type and suggests a more specific type. This type is inferred from the actual code.

Loading history...
62
     */
63
    public function setConfig($name = null, $value = null)
64
    {
65
        if (null === $this->configs) {
66
           $this->initConfig();
67
        }
68
       $this->configs[$name] = $value;
69
        $this->addLog("Setting config '{$name}' : " . $this->configs[$name]);
70
71
        return $this->configs[$name];
72
    }
73
74
    /**
75
     * @return string
76
     */
77
    public function getDirname()
78
    {
79
        return $this->dirname;
80
    }
81
}
82