Completed
Pull Request — master (#489)
by Richard
10:39
created

Mail   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 19
Duplicated Lines 100 %

Coupling/Cohesion

Components 0
Dependencies 1

Test Coverage

Coverage 0%
Metric Value
wmc 1
lcom 0
cbo 1
dl 19
loc 19
rs 10
ccs 0
cts 5
cp 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A __construct() 6 6 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
/*
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\Form;
13
14
/**
15
 * Mail - a email address element
16
 *
17
 * @category  Xoops\Form\Mail
18
 * @package   Xoops\Form
19
 * @author    Kazumi Ono <[email protected]>
20
 * @copyright 2001-2015 XOOPS Project (http://xoops.org)
21
 * @license   GNU GPL 2 or later (http://www.gnu.org/licenses/gpl-2.0.html)
22
 * @link      http://xoops.org
23
 */
24 View Code Duplication
class Mail extends Text
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...
25
{
26
    /**
27
     * Constructor
28
     *
29
     * @param string  $caption     Caption
30
     * @param string  $name        name attribute
31
     * @param integer $size        Size
32
     * @param integer $maxlength   Maximum length of text
33
     * @param string  $value       Initial text
34
     * @param string  $placeholder placeholder for this element.
35
     */
36
    public function __construct($caption, $name, $size, $maxlength, $value = '', $placeholder = '')
37
    {
38
        parent::__construct($caption, $name, $size, $maxlength, $value, $placeholder);
39
        $this->set('type', 'email');
40
        $this->setPattern('[^@]+@[^@]+\.[a-zA-Z]{2,6}', \XoopsLocale::ENTER_VALID_EMAIL);
41
    }
42
}
43