Blog   A
last analyzed

Complexity

Total Complexity 13

Size/Duplication

Total Lines 99
Duplicated Lines 0 %

Coupling/Cohesion

Components 3
Dependencies 1

Importance

Changes 3
Bugs 0 Features 1
Metric Value
wmc 13
c 3
b 0
f 1
lcom 3
cbo 1
dl 0
loc 99
rs 10

8 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 3 1
A getValues() 0 3 1
A getConfiguration() 0 11 2
A getForceLoginComment() 0 7 2
A getArticleIndex() 0 8 2
A getValidateComment() 0 7 2
A getCategory() 0 7 2
A setValues() 0 3 1
1
<?php
2
	namespace modules\blog\app\controller;
3
	
4
	
5
	use core\App;
6
	
7
	class Blog {
8
		private static $force_login_comment;
9
		private static $article_index;
10
		private static $validate_comment;
11
		private static $category;
12
		
13
		public static $router_parameter;
14
		
15
		private static $values = [];
16
		
17
		//-------------------------- BUILDER ----------------------------------------------------------------------------//
18
		public function __construct() {
19
			
20
		}
21
		//-------------------------- END BUILDER ----------------------------------------------------------------------------//
22
		
23
		
24
		//-------------------------- GETTER ----------------------------------------------------------------------------//
25
		/**
26
		 * @return array
27
		 * get array of all values wich will be used in the page
28
		 */
29
		public static function getValues() {
30
			return ["blog" => self::$values];
31
		}
32
		
33
		/**
34
		 * this function load the configuration of the blog
35
		 */
36
		private static function getConfiguration() {
37
			$dbc = App::getDb();
38
			
39
			$query = $dbc->select()->from("_blog_configuration")->where("ID_configuration", "=", 1)->get();
40
			
41
			foreach ($query as $obj) {
42
				self::$force_login_comment = $obj->force_login_comment;
43
				self::$article_index = $obj->article_index;
44
				self::$validate_comment = $obj->validate_comment;
45
			}
46
		}
47
		
48
		/**
49
		 * @return mixed
50
		 * this function get force login comment, if return 1 the user must be connected to post a comment
51
		 * on the article
52
		 */
53
		public static function getForceLoginComment() {
54
			if (self::$force_login_comment == null) {
55
				self::getConfiguration();
56
			}
57
			
58
			return self::$force_login_comment;
59
		}
60
		
61
		/*
62
		 * funciton that return the max nuber of article that we will get on index page
63
		 */
64
		public static function getArticleIndex() {
65
			if (self::$article_index == null) {
66
				Blog::getConfiguration();
67
				
68
			}
69
			
70
			return self::$article_index;
71
		}
72
		
73
		/**
74
		 * @return mixed
75
		 * function return if a comment must be validate to be displayed on the website only if this function
76
		 * return 1
77
		 */
78
		public static function getValidateComment() {
79
			if (self::$validate_comment == null) {
80
				self::getConfiguration();
81
			}
82
			
83
			return self::$validate_comment;
84
		}
85
		
86
		public static function getCategory() {
87
			if (self::$category == null) {
88
				self::$category = new Category();
89
			}
90
			
91
			return self::$category;
92
		}
93
		//-------------------------- END GETTER ----------------------------------------------------------------------------//
94
		
95
		
96
		//-------------------------- SETTER ----------------------------------------------------------------------------//
97
		/**
98
		 * @param $values
99
		 * can set values while keep older infos
100
		 */
101
		public static function setValues($values) {
102
			Blog::$values = array_merge(Blog::$values, $values);
103
		}
104
		//-------------------------- END SETTER ----------------------------------------------------------------------------//    
105
	}