Passed
Push — master ( 0b66f1...490f47 )
by Michael
19:57
created

XoopsCode   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 125
Duplicated Lines 0 %

Test Coverage

Coverage 56.76%

Importance

Changes 0
Metric Value
dl 0
loc 125
rs 10
c 0
b 0
f 0
ccs 42
cts 74
cp 0.5676
wmc 2

1 Method

Rating   Name   Duplication   Size   Complexity  
B registerExtensionProcessing() 0 113 2
1
<?php
2
/*
3
 You may not change or alter any portion of this comment or credits
4
 of supporting developers from this source code or any supporting source code
5
 which is considered copyrighted (c) material of the original comment or credit authors.
6
7
 This program is distributed in the hope that it will be useful,
8
 but WITHOUT ANY WARRANTY; without even the implied warranty of
9
 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
10
*/
11
12
namespace Xoops\Core\Text\Sanitizer\Extensions;
13
14
use Xoops\Core\Text\Sanitizer;
15
use Xoops\Core\Text\Sanitizer\ExtensionAbstract;
16
17
/**
18
 * TextSanitizer extension
19
 *
20
 * @category  Sanitizer
21
 * @package   Xoops\Core\Text
22
 * @author    iHackCode <https://github.com/ihackcode>
23
 * @copyright 2011-2015 XOOPS Project (http://xoops.org)
24
 * @license   GNU GPL 2 (http://www.gnu.org/licenses/gpl-2.0.html)
25
 * @link      http://xoops.org
26
 */
27
class XoopsCode extends ExtensionAbstract
28
{
29
    /**
30
     * @var array default configuration values
31
     */
32
    protected static $defaultConfiguration = ['enabled' => true];
33
34
    /**
35
     * Register extension with the supplied sanitizer instance
36
     *
37
     * @return void
38
     */
39 20
    public function registerExtensionProcessing()
40
    {
41 20
        $shortcodes = $this->shortcodes;
42
43 20
        $shortcodes->addShortcode(
44 20
            'siteurl',
45
            function ($attributes, $content, $tagName) use ($shortcodes) {
0 ignored issues
show
Unused Code introduced by
The parameter $tagName is not used and could be removed. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unused  annotation

45
            function ($attributes, $content, /** @scrutinizer ignore-unused */ $tagName) use ($shortcodes) {

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
46
                $url = ltrim($attributes[0], '=');
47
                $url = \Xoops::getInstance()->url($url);
48
                $newcontent = '<a href="' .$url. '">' . $shortcodes->process($content) . '</a>';
49
                return $newcontent;
50 20
            }
51
        );
52
53 20
        $shortcodes->addShortcode(
54 20
            'url',
55
            function ($attributes, $content, $tagName) use ($shortcodes) {
0 ignored issues
show
Unused Code introduced by
The parameter $tagName is not used and could be removed. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unused  annotation

55
            function ($attributes, $content, /** @scrutinizer ignore-unused */ $tagName) use ($shortcodes) {

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
56
                $url = ltrim($attributes[0], '=');
57
                $url = \Xoops::getInstance()->url($url);
58
                $newcontent = '<a href="' .$url. '">' . $shortcodes->process($content) . '</a>';
59
                return $newcontent;
60 20
            }
61
        );
62
63 20
        $shortcodes->addShortcode(
64 20
            'color',
65
            function ($attributes, $content, $tagName) use ($shortcodes) {
0 ignored issues
show
Unused Code introduced by
The parameter $tagName is not used and could be removed. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unused  annotation

65
            function ($attributes, $content, /** @scrutinizer ignore-unused */ $tagName) use ($shortcodes) {

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
66
                $color = ltrim($attributes[0], '=');
67
                $color = preg_match('/^[a-f0-9]{3}$|^[a-f0-9]{6}$/i', $color) ? '#' . $color : $color;
68
                $newcontent = '<span style="color: ' .$color. '">' . $shortcodes->process($content) . '</span>';
69
                return $newcontent;
70 20
            }
71
        );
72
73 20
        $shortcodes->addShortcode(
74 20
            'size',
75
            function ($attributes, $content, $tagName) use ($shortcodes) {
0 ignored issues
show
Unused Code introduced by
The parameter $tagName is not used and could be removed. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unused  annotation

75
            function ($attributes, $content, /** @scrutinizer ignore-unused */ $tagName) use ($shortcodes) {

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
76
                $size = ltrim($attributes[0], '=');
77
                $newcontent = '<span style="font-size: ' .$size. '">' . $shortcodes->process($content) . '</span>';
78
                return $newcontent;
79 20
            }
80
        );
81
82 20
        $shortcodes->addShortcode(
83 20
            'font',
84
            function ($attributes, $content, $tagName) use ($shortcodes) {
0 ignored issues
show
Unused Code introduced by
The parameter $tagName is not used and could be removed. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unused  annotation

84
            function ($attributes, $content, /** @scrutinizer ignore-unused */ $tagName) use ($shortcodes) {

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
85
                $font = ltrim($attributes[0], '=');
86
                $newcontent = '<span style="font-family: ' .$font. '">' . $shortcodes->process($content) . '</span>';
87
                return $newcontent;
88 20
            }
89
        );
90
91 20
        $shortcodes->addShortcode(
92 20
            'email',
93
            function ($attributes, $content, $tagName) {
0 ignored issues
show
Unused Code introduced by
The parameter $tagName is not used and could be removed. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unused  annotation

93
            function ($attributes, $content, /** @scrutinizer ignore-unused */ $tagName) {

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
94
                $newcontent = '<a href="mailto:' . trim($content) . '</a>';
95
                return $newcontent;
96 20
            }
97
        );
98
99 20
        $shortcodes->addShortcode(
100 20
            'b',
101
            function ($attributes, $content, $tagName) use ($shortcodes) {
0 ignored issues
show
Unused Code introduced by
The parameter $tagName is not used and could be removed. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unused  annotation

101
            function ($attributes, $content, /** @scrutinizer ignore-unused */ $tagName) use ($shortcodes) {

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
102 1
                $newcontent = '<strong>' . $shortcodes->process($content) . '</strong>';
103 1
                return $newcontent;
104 20
            }
105
        );
106
107 20
        $shortcodes->addShortcode(
108 20
            'i',
109
            function ($attributes, $content, $tagName) use ($shortcodes) {
0 ignored issues
show
Unused Code introduced by
The parameter $tagName is not used and could be removed. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unused  annotation

109
            function ($attributes, $content, /** @scrutinizer ignore-unused */ $tagName) use ($shortcodes) {

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
110
                $newcontent = '<em>' . $shortcodes->process($content) . '</em>';
111
                return $newcontent;
112 20
            }
113
        );
114
115 20
        $shortcodes->addShortcode(
116 20
            'u',
117
            function ($attributes, $content, $tagName) use ($shortcodes) {
0 ignored issues
show
Unused Code introduced by
The parameter $tagName is not used and could be removed. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unused  annotation

117
            function ($attributes, $content, /** @scrutinizer ignore-unused */ $tagName) use ($shortcodes) {

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
118
                $newcontent = '<u>' . $shortcodes->process($content) . '</u>';
119
                return $newcontent;
120 20
            }
121
        );
122
123 20
        $shortcodes->addShortcode(
124 20
            'd',
125
            function ($attributes, $content, $tagName) use ($shortcodes) {
0 ignored issues
show
Unused Code introduced by
The parameter $tagName is not used and could be removed. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unused  annotation

125
            function ($attributes, $content, /** @scrutinizer ignore-unused */ $tagName) use ($shortcodes) {

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
126
                $newcontent = '<del>' . $shortcodes->process($content) . '</del>';
127
                return $newcontent;
128 20
            }
129
        );
130
131 20
        $shortcodes->addShortcode(
132 20
            'center',
133
            function ($attributes, $content, $tagName) use ($shortcodes) {
0 ignored issues
show
Unused Code introduced by
The parameter $tagName is not used and could be removed. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unused  annotation

133
            function ($attributes, $content, /** @scrutinizer ignore-unused */ $tagName) use ($shortcodes) {

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
134
                $newcontent = '<div style="text-align: center;">' . $shortcodes->process($content) . '</div>';
135
                return $newcontent;
136 20
            }
137
        );
138
139 20
        $shortcodes->addShortcode(
140 20
            'left',
141
            function ($attributes, $content, $tagName) use ($shortcodes) {
0 ignored issues
show
Unused Code introduced by
The parameter $tagName is not used and could be removed. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unused  annotation

141
            function ($attributes, $content, /** @scrutinizer ignore-unused */ $tagName) use ($shortcodes) {

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
142
                $newcontent = '<div style="text-align: left;">' . $shortcodes->process($content) . '</div>';
143
                return $newcontent;
144 20
            }
145
        );
146
147 20
        $shortcodes->addShortcode(
148 20
            'right',
149
            function ($attributes, $content, $tagName) use ($shortcodes) {
0 ignored issues
show
Unused Code introduced by
The parameter $tagName is not used and could be removed. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unused  annotation

149
            function ($attributes, $content, /** @scrutinizer ignore-unused */ $tagName) use ($shortcodes) {

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
150
                $newcontent = '<div style="text-align: right;">' . $shortcodes->process($content) . '</div>';
151
                return $newcontent;
152 20
            }
153
        );
154 20
    }
155
}
156