Passed
Push — 1.0.0-dev ( 93958a...e1c8ef )
by nguereza
02:26
created

BaseStaticClass::getLogger()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 8
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
cc 2
eloc 6
c 1
b 0
f 1
nc 2
nop 0
dl 0
loc 8
rs 10
1
<?php
2
	defined('ROOT_PATH') || exit('Access denied');
3
	/**
4
	 * TNH Framework
5
	 *
6
	 * A simple PHP framework using HMVC architecture
7
	 *
8
	 * This content is released under the GNU GPL License (GPL)
9
	 *
10
	 * Copyright (C) 2017 Tony NGUEREZA
11
	 *
12
	 * This program is free software; you can redistribute it and/or
13
	 * modify it under the terms of the GNU General Public License
14
	 * as published by the Free Software Foundation; either version 3
15
	 * of the License, or (at your option) any later version.
16
	 *
17
	 * This program is distributed in the hope that it will be useful,
18
	 * but WITHOUT ANY WARRANTY; without even the implied warranty of
19
	 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
20
	 * GNU General Public License for more details.
21
	 *
22
	 * You should have received a copy of the GNU General Public License
23
	 * along with this program; if not, write to the Free Software
24
	 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
25
	*/
26
27
	class BaseStaticClass{
28
		/**
29
		 * The logger instance
30
		 * @var object
31
		 */
32
		protected static $logger;
33
34
		/**
35
		 * The signleton of the logger
36
		 * @return Object the Log instance
37
		 */
38
		public static function getLogger(){
39
			if(self::$logger == null){
40
				$logger = array();
41
				$logger[0] =& class_loader('Log', 'classes');
42
				$logger[0]->setLogger('Class::' . get_called_class());
43
				self::$logger = $logger[0];
44
			}
45
			return self::$logger;			
46
		}
47
48
		/**
49
		 * Set the log instance for future use
50
		 * @param object $logger the log object
51
		 * @return object the log instance
52
		 */
53
		public static function setLogger($logger){
54
			self::$logger = $logger;
55
			return self::$logger;
56
		}
57
58
	}
59