Completed
Push — master ( 8271d0...ee7cb3 )
by Anthony
02:03
created

Category   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 45
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Importance

Changes 0
Metric Value
wmc 5
lcom 0
cbo 1
dl 0
loc 45
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 3 1
B getCategoryArticle() 0 25 4
1
<?php
2
	namespace modules\blog\app\controller;
3
	
4
	
5
	use core\App;
6
	
7
	class Category {
8
		
9
		
10
		//-------------------------- BUILDER ----------------------------------------------------------------------------//
11
		public function __construct() {
12
			
13
		}
14
		//-------------------------- END BUILDER ----------------------------------------------------------------------------//
15
		
16
		
17
		//-------------------------- GETTER ----------------------------------------------------------------------------//
18
		/**
19
		 * get all categories of an article
20
		 */
21
		public function getCategoryArticle() {
22
			$dbc = App::getDb();
23
			
24
			$query = $dbc->select()
25
				->from("_blog_article")
26
				->from("_blog_category")
27
				->from("_blog_article_category")
28
				->where("_blog_article.ID_article", "=", Blog::$parametre_router, "OR")
29
				->where("_blog_article.url", "=", Blog::$parametre_router, "AND")
30
				->where("_blog_article_category.ID_article", "=", "_blog_article.ID_article", "AND", true)
31
				->where("_blog_article_category.ID_category", "=", "_blog_category.ID_category", "", true)
32
				->get();
33
			
34
			if ((is_array($query)) && (count($query) > 0)) {
35
				$categories = [];
36
				foreach ($query as $obj) {
37
					$categories = [
38
						"id_category" => $obj->ID_category,
39
						"category" => $obj->category
40
					];
41
				}
42
				
43
				App::setValues(["categories" => $categories]);
44
			}
45
		}
46
		//-------------------------- END GETTER ----------------------------------------------------------------------------//
47
		
48
		
49
		//-------------------------- SETTER ----------------------------------------------------------------------------//
50
		//-------------------------- END SETTER ----------------------------------------------------------------------------//    
51
	}