Completed
Push — master ( 8b38a2...313d97 )
by Mikael
04:15
created

CFormContact   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 25
Duplicated Lines 100 %

Coupling/Cohesion

Components 0
Dependencies 0

Importance

Changes 0
Metric Value
dl 25
loc 25
rs 10
c 0
b 0
f 0
wmc 3
lcom 0
cbo 0

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
// Include CForm
3
include('../../autoloader.php');
4
5
6
/**
7
 * Create a class for a contact-form with name, email and phonenumber.
8
 */
9
class CFormContact extends \Mos\HTMLForm\CForm {
0 ignored issues
show
Bug introduced by
The type Mos\HTMLForm\CForm was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
10
11
12
  /** Create all form elements and validation rules in the constructor.
13
   *
14
   */
15
  public function __construct() {
16
    parent::__construct();
17
    
18
    $this->AddElement(new \Mos\HTMLForm\CFormElementText('name'))
0 ignored issues
show
Bug introduced by
The type Mos\HTMLForm\CFormElementText was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
19
         ->AddElement(new \Mos\HTMLForm\CFormElementText('email'))
20
         ->AddElement(new \Mos\HTMLForm\CFormElementText('phone'))
21
         ->AddElement(new \Mos\HTMLForm\CFormElementSubmit('submit', array('callback'=>array($this, 'DoSubmit'))));
0 ignored issues
show
Bug introduced by
The type Mos\HTMLForm\CFormElementSubmit was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
22
  }
23
24
25
  /**
26
   * Callback for submitted forms
27
   */
28
  protected function DoSubmit() {
29
    echo "<p><i>DoSubmit(): Form was submitted. Do stuff (save to database) and return true (success) or false (failed processing form)</i></p>";
30
    return true;
31
  }
32
33
}
34
35
36
// -----------------------------------------------------------------------
37
//
38
// Use the form and check it status.
39
//
40
session_name('cform_example');
41
session_start();
42
$form = new CFormContact();
43
44
?>
45
46
47
<!doctype html>
48
<meta charset=utf8>
49
<title>CForm Example: Basic example on how to use CForm (part 1)</title>
50
<h1>CForm Example: Basic example on how to use CForm (part 1)</h1>
51
<?=$form->GetHTML()?>
52
53
<?php $footer = "footer_mos.php"; if(is_file($footer)) include($footer) ?>
54