Completed
Push — master ( 375a6b...8786b6 )
by Michael
02:15
created

RandomQuoteUtilities::setMetaKeywordsRandomquote()   A

Complexity

Conditions 3
Paths 2

Size

Total Lines 11
Code Lines 8

Duplication

Lines 11
Ratio 100 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 11
loc 11
rs 9.4285
cc 3
eloc 8
nc 2
nop 1
1
<?php
2
3
/**
4
 * Module: RandomQuote
5
 *
6
 * You may not change or alter any portion of this comment or credits
7
 * of supporting developers from this source code or any supporting source code
8
 * which is considered copyrighted (c) material of the original comment or credit authors.
9
 *
10
 * PHP version 5
11
 *
12
 * @category        Module
13
 * @package         Randomquote
14
 * @author          XOOPS Development Team, Mamba
15
 * @copyright       2001-2016 XOOPS Project (http://xoops.org)
16
 * @license         GNU GPL 2 or later (http://www.gnu.org/licenses/gpl-2.0.html)
17
 * @link            http://xoops.org/
18
 * @since           2.0.0
19
 */
20
class RandomQuoteUtilities
0 ignored issues
show
Coding Style Compatibility introduced by
PSR1 recommends that each class must be in a namespace of at least one level to avoid collisions.

You can fix this by adding a namespace to your class:

namespace YourVendor;

class YourClass { }

When choosing a vendor namespace, try to pick something that is not too generic to avoid conflicts with other libraries.

Loading history...
21
{
22
23
    /***************Blocks**************
24
     * @param $cats
25
     * @return string
26
     */
27
    public static function randomquote_block_addCatSelect($cats)
28
    {
29
        $cat_sql = '';
30
        if (is_array($cats)) {
31
            $cat_sql = '(' . current($cats);
32
            array_shift($cats);
33
            foreach ($cats as $cat) {
34
                $cat_sql .= ',' . $cat;
35
            }
36
            $cat_sql .= ')';
37
        }
38
39
        return $cat_sql;
40
    }
41
42
    /**
43
     * @param               $global
44
     * @param               $key
45
     * @param  string       $default
46
     * @param  string       $type
47
     * @return mixed|string
48
     */
49
    public static function cleanVarsRandomquote(&$global, $key, $default = '', $type = 'int')
50
    {
51
        switch ($type) {
52
            case 'string':
53
                $ret = isset($global[$key]) ? filter_var($global[$key], FILTER_SANITIZE_MAGIC_QUOTES) : $default;
54
                break;
55
            case 'int':
56
            default:
57
                $ret = isset($global[$key]) ? filter_var($global[$key], FILTER_SANITIZE_NUMBER_INT) : $default;
58
                break;
59
        }
60
        if ($ret === false) {
61
            return $default;
62
        }
63
64
        return $ret;
65
    }
66
67
    /**
68
     * @param $content
69
     */
70 View Code Duplication
    public static function setMetaKeywordsRandomquote($content)
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
71
    {
72
        global $xoopsTpl, $xoTheme;
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...
73
        $myts    = MyTextSanitizer::getInstance();
74
        $content = $myts->undoHtmlSpecialChars($myts->displayTarea($content));
75
        if (isset($xoTheme) && is_object($xoTheme)) {
76
            $xoTheme->addMeta('meta', 'keywords', strip_tags($content));
77
        } else { // Compatibility for old Xoops versions
78
            $xoopsTpl->assign('xoops_meta_keywords', strip_tags($content));
79
        }
80
    }
81
82
    /**
83
     * @param $content
84
     */
85 View Code Duplication
    public static function setMetaDescriptionRandomquote($content)
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
86
    {
87
        global $xoopsTpl, $xoTheme;
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...
88
        $myts    = MyTextSanitizer::getInstance();
89
        $content = $myts->undoHtmlSpecialChars($myts->displayTarea($content));
90
        if (isset($xoTheme) && is_object($xoTheme)) {
91
            $xoTheme->addMeta('meta', 'description', strip_tags($content));
92
        } else { // Compatibility for old Xoops versions
93
            $xoopsTpl->assign('xoops_meta_description', strip_tags($content));
94
        }
95
    }
96
}
97