Completed
Push — master ( a12ace...998a95 )
by Federico
02:48
created

Module   A

Complexity

Total Complexity 27

Size/Duplication

Total Lines 73
Duplicated Lines 8.22 %

Coupling/Cohesion

Components 1
Dependencies 0

Importance

Changes 11
Bugs 0 Features 1
Metric Value
wmc 27
c 11
b 0
f 1
lcom 1
cbo 0
dl 6
loc 73
rs 10

12 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 7 1
A getCss() 0 3 1
A getJs() 0 3 1
B getJsVariables() 0 12 6
A addModules() 0 4 2
A addModule() 0 3 1
A addFiles() 0 4 2
A addFile() 0 3 1
A addFilesRequired() 0 4 2
A addFileRequired() 0 3 1
A addDipendences() 0 5 1
B getRequire() 6 12 8

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
	class Module {
0 ignored issues
show
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 $name;
4
		public $modules;
5
		public $files;
6
		public $required;
7
		public $data;
8
		public function __construct() {
9
			$this->name			= get_class($this);
10
			$this->modules	= [];
11
			$this->files		= [];
12
			$this->required	= [];
13
			$this->data			= [];
14
		}
15
		// abstract public function config();
0 ignored issues
show
Unused Code Comprehensibility introduced by
55% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
16
		// abstract public function init();
0 ignored issues
show
Unused Code Comprehensibility introduced by
55% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
17
		// abstract public function draw();
0 ignored issues
show
Unused Code Comprehensibility introduced by
55% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
18
		public function getCss() {
19
			return $this->getRequire("getCss",".css");
20
		}
21
		public function getJs() {
22
			return $this->getRequire("getJs",".js");
23
		}
24
		public function getJsVariables() {
25
			$temp = [];
26
			foreach ($this->required as $i)
27
				if (is_array($i))
28
					array_push($temp,$i);
29
			foreach ($this->modules as $i)
30
				$temp = array_merge( $temp, $i->getJsVariables() );
31
			foreach ($this->files as $i)
32
				if (is_array($i))
33
					array_push($temp,$i);
34
			return $temp;
35
		}
36
		public function addModules( $_mods ) {
37
			foreach ($_mods as $value)
38
				$this->addModule($value);
39
		}
40
		public function addModule( $_mod ) {
41
			$this->modules[$_mod->name] = $_mod;
42
		}
43
		public function addFiles( $_files ) {
44
			foreach ($_files as $value)
45
				$this->addFile($value);
46
		}
47
		public function addFile( $_file ) {
48
			array_push($this->files, $_file);
49
		}
50
		public function addFilesRequired( $_files ) {
51
			foreach ($_files as $value)
52
				$this->addFileRequired($value);
53
		}
54
		public function addFileRequired( $_file ) {
55
			array_push($this->required, $_file);
56
		}
57
		protected function addDipendences() {
58
			$this->data["css"] = $this->getCss();
59
			$this->data["js"] = $this->getJs();
60
			$this->data["jsVariables"] = $this->getJsVariables();
61
		}
62
		protected function getRequire( $_function, $_extenction) {
63
			$temp = [];
64 View Code Duplication
			foreach ($this->required as $i)
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across 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...
65
				if (!is_array($i) && strpos($i, $_extenction) !== FALSE)
66
					array_push($temp,$i);
67
			foreach ($this->modules as $i)
68
				$temp = array_merge( $temp, $i->$_function() );
69 View Code Duplication
			foreach ($this->files as $i)
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across 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...
70
				if (!is_array($i) && strpos($i, $_extenction) !== FALSE)
71
					array_push($temp,$i);
72
			return $temp;
73
		}
74
	}
75
?>
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...
76