Completed
Push — master ( a25af9...a12ace )
by Federico
02:41
created

Template   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 30
Duplicated Lines 100 %

Coupling/Cohesion

Components 0
Dependencies 2

Importance

Changes 14
Bugs 1 Features 0
Metric Value
wmc 3
c 14
b 1
f 0
lcom 0
cbo 2
dl 30
loc 30
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 16 16 1
A makeConnection() 12 12 2

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 View Code Duplication
	class Template extends Html {
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...
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...
3
		public function __construct() {
4
			parent::__construct();
5
			$this->data["brand"]		= "JATE";
6
			$this->data["brandImg"] = "";
7
			$this->data["title"]		= "JATE";
8
			$this->data["template"] = "guis/tradictional.html";
9
			$this->addFiles([
10
					"https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css"
11
				, "https://code.jquery.com/jquery-1.11.3.min.js"
12
				, "https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js"
13
			]);
14
			$this->data["metaDescription"] = "Beautiful description .";
15
			$this->data["metaKeywords"] = "JATE,PHP,JS,CSS";
16
			$this->data["metaAuthor"] = "XaBerr";
17
			$this->makeConnection();
18
		}
19
		public function makeConnection() {
20
			global $jConfig;
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...
21
			$connection = null;
22
			if($jConfig->connection["enable"])
23
				$connection = new Connection(
24
						$jConfig->connection["server"]
25
					, $jConfig->connection["database"]
26
					, $jConfig->connection["user"]
27
					, $jConfig->connection["password"]
28
				);
29
			$this->addConnection("base",$connection);
30
		}
31
	}
32
?>
0 ignored issues
show
Best Practice introduced by
It is not recommended to use PHP's closing tag ?> in files other than templates.

Using a closing tag in PHP files that only contain PHP code is not recommended as you might accidentally add whitespace after the closing tag which would then be output by PHP. This can cause severe problems, for example headers cannot be sent anymore.

A simple precaution is to leave off the closing tag as it is not required, and it also has no negative effects whatsoever.

Loading history...
33