Completed
Push — master ( 171474...8d265e )
by Michael
01:31
created

RandomquoteQuotes   A

Complexity

Total Complexity 12

Size/Duplication

Total Lines 107
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Importance

Changes 0
Metric Value
dl 0
loc 107
rs 10
c 0
b 0
f 0
wmc 12
lcom 0
cbo 0

5 Methods

Rating   Name   Duplication   Size   Complexity  
A Quotes::__construct() 0 10 1
A Quotes::getForm() 0 7 1
A Quotes::getGroupsRead() 0 6 1
A Quotes::getGroupsSubmit() 0 6 1
A Quotes::getGroupsModeration() 0 6 1
1
<?php namespace Xoopsmodules\randomquote;
0 ignored issues
show
Coding Style Compatibility introduced by
For compatibility and reusability of your code, PSR1 recommends that a file should introduce either new symbols (like classes, functions, etc.) or have side-effects (like outputting something, or including other files), but not both at the same time. The first symbol is defined on line 33 and the first side effect is on line 26.

The PSR-1: Basic Coding Standard recommends that a file should either introduce new symbols, that is classes, functions, constants or similar, or have side effects. Side effects are anything that executes logic, like for example printing output, changing ini settings or writing to a file.

The idea behind this recommendation is that merely auto-loading a class should not change the state of an application. It also promotes a cleaner style of programming and makes your code less prone to errors, because the logic is not spread out all over the place.

To learn more about the PSR-1, please see the PHP-FIG site on the PSR-1.

Loading history...
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
 * Module: randomquote
14
 *
15
 * @category        Module
16
 * @package         randomquote
17
 * @author          XOOPS Development Team <[email protected]> - <https://xoops.org>
18
 * @copyright       {@link https://xoops.org/ XOOPS Project}
19
 * @license         GPL 2.0 or later
20
 * @link            https://xoops.org/
21
 * @since           1.0.0
22
 */
23
use Xoopsmodules\randomquote;
24
use Xoopsmodules\randomquote\form;
25
26
$moduleDirName = basename(dirname(__DIR__));
27
28
$permHelper = new \Xmf\Module\Helper\Permission();
29
30
/**
31
 * Class Quotes
32
 */
33
class Quotes extends \XoopsObject
34
{
35
    /**
36
     * Constructor
37
     *
38
     * @param null
39
     */
40
    public function __construct()
41
    {
42
        parent::__construct();
43
        $this->initVar('id', XOBJ_DTYPE_INT);
44
        $this->initVar('quote', XOBJ_DTYPE_OTHER);
45
        $this->initVar('author', XOBJ_DTYPE_TXTBOX);
46
        $this->initVar('online', XOBJ_DTYPE_INT);
47
        $this->initVar('created', XOBJ_DTYPE_TIMESTAMP);
48
        $this->initVar('cid', XOBJ_DTYPE_INT);
49
    }
50
51
    /**
52
     * Get form
53
     *
54
     * @return \Xoopsmodules\randomquote\form\QuotesForm
55
     */
56
    public function getForm()
57
    {
58
        require_once XOOPS_ROOT_PATH . '/modules/randomquote/class/form/QuotesForm.php';
59
60
        $form = new form\QuotesForm($this);
61
        return $form;
62
    }
63
64
    /**
65
     * @return array|null
66
     */
67
    public function getGroupsRead()
68
    {
69
        global $permHelper;
0 ignored issues
show
Compatibility Best Practice introduced by
Use of global functionality is not recommended; it makes your code harder to test, and less reusable.

Instead of relying on global state, we recommend one of these alternatives:

1. Pass all data via parameters

function myFunction($a, $b) {
    // Do something
}

2. Create a class that maintains your state

class MyClass {
    private $a;
    private $b;

    public function __construct($a, $b) {
        $this->a = $a;
        $this->b = $b;
    }

    public function myFunction() {
        // Do something
    }
}
Loading history...
70
        //return $this->publisher->getHandler('permission')->getGrantedGroupsById('quotes_read', id);
0 ignored issues
show
Unused Code Comprehensibility introduced by
69% 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...
71
        return $permHelper->getGroupsForItem('sbcolumns_read', $this->getVar('id'));
72
    }
73
74
    /**
75
     * @return array|null
76
     */
77
    public function getGroupsSubmit()
78
    {
79
        global $permHelper;
0 ignored issues
show
Compatibility Best Practice introduced by
Use of global functionality is not recommended; it makes your code harder to test, and less reusable.

Instead of relying on global state, we recommend one of these alternatives:

1. Pass all data via parameters

function myFunction($a, $b) {
    // Do something
}

2. Create a class that maintains your state

class MyClass {
    private $a;
    private $b;

    public function __construct($a, $b) {
        $this->a = $a;
        $this->b = $b;
    }

    public function myFunction() {
        // Do something
    }
}
Loading history...
80
        //        return $this->publisher->getHandler('permission')->getGrantedGroupsById('quotes_submit', id);
0 ignored issues
show
Unused Code Comprehensibility introduced by
65% 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...
81
        return $permHelper->getGroupsForItem('sbcolumns_submit', $this->getVar('id'));
82
    }
83
84
    /**
85
     * @return array|null
86
     */
87
    public function getGroupsModeration()
88
    {
89
        global $permHelper;
0 ignored issues
show
Compatibility Best Practice introduced by
Use of global functionality is not recommended; it makes your code harder to test, and less reusable.

Instead of relying on global state, we recommend one of these alternatives:

1. Pass all data via parameters

function myFunction($a, $b) {
    // Do something
}

2. Create a class that maintains your state

class MyClass {
    private $a;
    private $b;

    public function __construct($a, $b) {
        $this->a = $a;
        $this->b = $b;
    }

    public function myFunction() {
        // Do something
    }
}
Loading history...
90
        //        return $this->publisher->getHandler('permission')->getGrantedGroupsById('quotes_moderation', id);
0 ignored issues
show
Unused Code Comprehensibility introduced by
65% 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...
91
        return $permHelper->getGroupsForItem('sbcolumns_moderation', $this->getVar('id'));
92
    }
93
}
94
95