Test Setup Failed
Push — master ( ec638a...cb9435 )
by Julito
51:10
created

TestMatching   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 96
Duplicated Lines 100 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

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

4 Methods

Rating   Name   Duplication   Size   Complexity  
B getConfig() 26 26 2
A getMaximizedToolbar() 19 19 2
A getNormalToolbar() 17 17 1
A getMinimizedToolbar() 12 12 1

How to fix   Duplicated Code   

Duplicated Code

Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.

Common duplication problems, and corresponding solutions are:

1
<?php
2
/* For licensing terms, see /license.txt */
3
4
namespace Chamilo\CoreBundle\Component\Editor\CkEditor\Toolbar;
5
6
/**
7
 * TestFreeAnswer toolbar configuration
8
 *
9
 * @package Chamilo\CoreBundle\Component\Editor\CkEditor\Toolbar
10
 */
11 View Code Duplication
class TestMatching extends Basic
0 ignored issues
show
Duplication introduced by
This class 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...
12
{
13
    /**
14
     * Get the toolbar config
15
     * @return array
16
     */
17
    public function getConfig()
18
    {
19
        if (api_get_setting('more_buttons_maximized_mode') != 'true') {
20
            $config['toolbar'] = $this->getNormalToolbar();
21
        } else {
22
            $config['toolbar_minToolbar'] = $this->getMinimizedToolbar();
23
            $config['toolbar_maxToolbar'] = $this->getMaximizedToolbar();
24
        }
25
26
        $config['fullPage'] = false;
27
        $config['extraPlugins'] = 'wordcount';
28
        $config['wordcount'] = array(
29
            // Whether or not you want to show the Word Count
30
            'showWordCount' => true,
31
            // Whether or not you want to show the Char Count
32
            'showCharCount' => true,
33
            // Option to limit the characters in the Editor
34
            'charLimit' => 'unlimited',
35
            // Option to limit the words in the Editor
36
            'wordLimit' => 'unlimited'
37
        );
38
39
        //$config['height'] = '200';
40
41
        return $config;
42
    }
43
44
    /**
45
     * Get the toolbar configuration when CKEditor is maximized
46
     * @return array
47
     */
48
    protected function getMaximizedToolbar()
49
    {
50
        return [
51
            ['NewPage', 'Templates', '-', 'Preview', 'Print'],
52
            ['Cut', 'Copy', 'Paste', 'PasteText', 'PasteFromWord'],
53
            ['Undo', 'Redo', '-', 'SelectAll', 'Find', '-', 'RemoveFormat'],
54
            ['Link', 'Unlink', 'Anchor', 'Glossary'],
55
            ['Image', 'Mapping', 'Video', 'Oembed', 'Youtube', 'Flash', 'Audio', 'leaflet', 'Smiley', 'SpecialChar', 'Asciimath',],
56
            '/',
57
            ['Table', '-', 'CreateDiv'],
58
            ['BulletedList', 'NumberedList', 'HorizontalRule', '-', 'Outdent', 'Indent', 'Blockquote'],
59
            ['JustifyLeft', 'JustifyCenter', 'JustifyRight', 'JustifyBlock'],
60
            ['Bold', 'Italic', 'Underline', 'Strike', '-', 'Subscript', 'Superscript', '-', 'TextColor', 'BGColor'],
61
            [api_get_setting('allow_spellcheck') == 'true' ? 'Scayt' : ''],
62
            ['Styles', 'Format', 'Font', 'FontSize'],
63
            ['PageBreak', 'ShowBlocks'],
64
            ['Toolbarswitch']
65
        ];
66
    }
67
68
    /**
69
     * Get the default toolbar configuration when the setting more_buttons_maximized_mode is false
70
     * @return array
71
     */
72
    protected function getNormalToolbar()
73
    {
74
        return [
75
            [
76
                'Maximize',
77
                'Bold',
78
                'Image',
79
                'Link',
80
                'PasteFromWord',
81
                'Audio',
82
                'Table',
83
                'Subscript',
84
                'Superscript',
85
                'ShowBlocks'
86
            ]
87
        ];
88
    }
89
90
    /**
91
     * Get the toolbar configuration when CKEditor is minimized
92
     * @return array
93
     */
94
    protected function getMinimizedToolbar()
95
    {
96
        return [
97
            $this->getNewPageBlock(),
98
            ['Undo', 'Redo'],
99
            ['Link', 'Image', 'Video', 'Flash', 'Audio', 'Table', 'Asciimath'],
100
            ['BulletedList', 'NumberedList', 'HorizontalRule'],
101
            ['JustifyLeft', 'JustifyCenter', 'JustifyBlock'],
102
            ['Format', 'Font', 'FontSize', 'Bold', 'Italic', 'Underline', 'TextColor', 'BGColor'],
103
            ['Toolbarswitch']
104
        ];
105
    }
106
}
107