Passed
Push — master ( c51a0a...99fb41 )
by Anthony
02:59
created

Navigation::__construct()   B

Complexity

Conditions 5
Paths 4

Size

Total Lines 16
Code Lines 9

Duplication

Lines 0
Ratio 0 %

Importance

Changes 3
Bugs 0 Features 0
Metric Value
c 3
b 0
f 0
dl 0
loc 16
rs 8.8571
cc 5
eloc 9
nc 4
nop 0
1
<?php
2
	namespace core;
3
	class Navigation {
4
		
5
		
6
		
7
		//-------------------------- CONSTRUCTEUR ----------------------------------------------------------------------------//
8
		public function __construct() {
9
			$dbc = App::getDb();
10
11
			$query = $dbc->select()->from("navigation")->orderBy("ordre")->get();
12
13
			if (is_array($query) && (count($query) > 0)) {
14
				foreach ($query as $obj) {
15
					if ($obj->ID_page === null) {
16
						$this->getLienNavigationModule($obj->ID_module);
17
					}
18
					else {
19
						$this->getLienNavigationPage($obj->ID_page);
20
					}
21
				}
22
			}
23
		}
24
		//-------------------------- FIN CONSTRUCTEUR ----------------------------------------------------------------------------//
25
		
26
		
27
		
28
		//-------------------------- GETTER ----------------------------------------------------------------------------//
29 View Code Duplication
		private function getLienNavigationPage($id_page) {
0 ignored issues
show
Duplication introduced by
This method 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...
30
			$dbc = App::getDb();
31
32
			$query = $dbc->select()
33
				->from("navigation")
34
				->from("page")
35
				->where("navigation.ID_page", "=", "page.ID_page", "AND")
36
				->where("page.ID_page", "=", $id_page)
37
				->get();
38
39
			if (is_array($query) && (count($query) > 0)) {
40
				foreach ($query as $obj) {
41
					echo($obj->titre." ++ ".$obj->url."<br>");
42
				}
43
			}
44
		}
45
46 View Code Duplication
		private function getLienNavigationModule($id_module) {
0 ignored issues
show
Duplication introduced by
This method 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...
47
			$dbc = App::getDb();
48
49
			$query = $dbc->select()
50
				->from("navigation")
51
				->from("module")
52
				->where("navigation.ID_module", "=", "module.ID_module", "AND")
53
				->where("module.ID_module", "=", $id_module)
54
				->get();
55
56
			if (is_array($query) && (count($query) > 0)) {
57
				foreach ($query as $obj) {
58
					echo($obj->nom_module." ++ ".$obj->url."<br>");
59
				}
60
			}
61
		}
62
		//-------------------------- FIN GETTER ----------------------------------------------------------------------------//
63
		
64
		
65
		
66
		//-------------------------- SETTER ----------------------------------------------------------------------------//
67
		//-------------------------- FIN SETTER ----------------------------------------------------------------------------//
68
	}