Passed
Push — master ( 6af1fb...f5fe55 )
by Michael
02:53 queued 10s
created

Uservotedata   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 67
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 5
eloc 22
c 1
b 0
f 0
dl 0
loc 67
rs 10

5 Methods

Rating   Name   Duplication   Size   Complexity  
A getGroupsRead() 0 6 1
A getForm() 0 3 1
A getGroupsModeration() 0 6 1
A __construct() 0 12 1
A getGroupsSubmit() 0 6 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace XoopsModules\Adslight;
6
7
/*
8
 You may not change or alter any portion of this comment or credits
9
 of supporting developers from this source code or any supporting source code
10
 which is considered copyrighted (c) material of the original comment or credit authors.
11
12
 This program is distributed in the hope that it will be useful,
13
 but WITHOUT ANY WARRANTY; without even the implied warranty of
14
 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
15
*/
16
17
/**
18
 * Module: Adslight
19
 *
20
 * @category        Module
21
 * @package         adslight
22
 * @author          XOOPS Development Team <https://xoops.org>
23
 * @copyright       {@link https://xoops.org/ XOOPS Project}
24
 * @license         GPL 2.0 or later
25
 * @link            https://xoops.org/
26
 * @since           1.0.0
27
 */
28
29
use XoopsModules\Adslight\{
30
    Helper
0 ignored issues
show
Bug introduced by
This use statement conflicts with another class in this namespace, XoopsModules\Adslight\Helper. Consider defining an alias.

Let?s assume that you have a directory layout like this:

.
|-- OtherDir
|   |-- Bar.php
|   `-- Foo.php
`-- SomeDir
    `-- Foo.php

and let?s assume the following content of Bar.php:

// Bar.php
namespace OtherDir;

use SomeDir\Foo; // This now conflicts the class OtherDir\Foo

If both files OtherDir/Foo.php and SomeDir/Foo.php are loaded in the same runtime, you will see a PHP error such as the following:

PHP Fatal error:  Cannot use SomeDir\Foo as Foo because the name is already in use in OtherDir/Foo.php

However, as OtherDir/Foo.php does not necessarily have to be loaded and the error is only triggered if it is loaded before OtherDir/Bar.php, this problem might go unnoticed for a while. In order to prevent this error from surfacing, you must import the namespace with a different alias:

// Bar.php
namespace OtherDir;

use SomeDir\Foo as SomeDirFoo; // There is no conflict anymore.
Loading history...
31
};
32
use Xmf\Module\Helper\Permission;
33
34
//$permHelper = new \Xmf\Module\Helper\Permission();
35
36
/**
37
 * Class Uservotedata
38
 */
39
class Uservotedata extends \XoopsObject
40
{
41
    public $helper;
42
    public $permHelper;
43
44
    /**
45
     * Constructor
46
     *
47
     * @param null
48
     */
49
    public function __construct()
50
    {
51
        parent::__construct();
52
        /** @var Helper $helper */
53
        $this->helper     = Helper::getInstance();
54
        $this->permHelper = new Permission();
55
        $this->initVar('ratingid', \XOBJ_DTYPE_INT);
56
        $this->initVar('usid', \XOBJ_DTYPE_INT);
57
        $this->initVar('ratinguser', \XOBJ_DTYPE_INT);
58
        $this->initVar('rating', \XOBJ_DTYPE_INT);
59
        $this->initVar('ratinghostname', \XOBJ_DTYPE_TXTBOX);
60
        $this->initVar('date_created', \XOBJ_DTYPE_INT);
61
    }
62
63
    /**
64
     * Get form
65
     *
66
     * @return \XoopsModules\Adslight\Form\UservotesForm
67
     */
68
    public function getForm(): Form\UservotesForm
69
    {
70
        return new Form\UservotesForm($this);
71
    }
72
73
    /**
74
     * @return array|null
75
     */
76
    public function getGroupsRead(): ?array
77
    {
78
        //$permHelper = new \Xmf\Module\Helper\Permission();
79
        return $this->permHelper->getGroupsForItem(
80
            'sbcolumns_read',
81
            $this->getVar('ratingid')
82
        );
83
    }
84
85
    /**
86
     * @return array|null
87
     */
88
    public function getGroupsSubmit(): ?array
89
    {
90
        //$permHelper = new \Xmf\Module\Helper\Permission();
91
        return $this->permHelper->getGroupsForItem(
92
            'sbcolumns_submit',
93
            $this->getVar('ratingid')
94
        );
95
    }
96
97
    /**
98
     * @return array|null
99
     */
100
    public function getGroupsModeration(): ?array
101
    {
102
        //$permHelper = new \Xmf\Module\Helper\Permission();
103
        return $this->permHelper->getGroupsForItem(
104
            'sbcolumns_moderation',
105
            $this->getVar('ratingid')
106
        );
107
    }
108
}
109