@@ -19,63 +19,69 @@ class LoggingUtil
19
19
private $ loggers = [];
20
20
21
21
/**
22
- * Singleton LogginUtil Instance
22
+ * Singleton LoggingUtil Instance
23
23
*
24
24
* @var LoggingUtil
25
25
*/
26
- private static $ INSTANCE ;
26
+ private static $ instance ;
27
27
28
28
/**
29
29
* Singleton accessor for instance variable
30
30
*
31
31
* @return LoggingUtil
32
32
*/
33
- public static function getInstance ()
33
+ public static function getInstance (): LoggingUtil
34
34
{
35
- if (self ::$ INSTANCE == null ) {
36
- self ::$ INSTANCE = new LoggingUtil ();
35
+ if (self ::$ instance = == null ) {
36
+ self ::$ instance = new LoggingUtil ();
37
37
}
38
38
39
- return self ::$ INSTANCE ;
39
+ return self ::$ instance ;
40
40
}
41
41
42
42
/**
43
- * Constructor for Logging Util
43
+ * Avoids instantiation of LoggingUtil by new.
44
44
*/
45
45
private function __construct ()
46
46
{
47
- // private constructor
47
+ }
48
+
49
+ /**
50
+ * Avoids instantiation of LoggingUtil by clone.
51
+ */
52
+ private function __clone ()
53
+ {
48
54
}
49
55
50
56
/**
51
57
* Creates a new logger instances based on class name if it does not exist. If logger instance already exists, the
52
58
* existing instance is simply returned.
53
59
*
54
- * @param string $clazz
60
+ * @param string $className
55
61
* @return MftfLogger
56
62
* @throws \Exception
57
63
*/
58
- public function getLogger ($ clazz )
64
+ public function getLogger ($ className ): MftfLogger
59
65
{
60
- if ($ clazz == null ) {
61
- throw new \Exception ("You must pass a class to receive a logger " );
66
+ if ($ className == null ) {
67
+ throw new \Exception ("You must pass a class name to receive a logger " );
62
68
}
63
69
64
- if (!array_key_exists ($ clazz , $ this ->loggers )) {
65
- $ logger = new MftfLogger ($ clazz );
70
+ if (!array_key_exists ($ className , $ this ->loggers )) {
71
+ $ logger = new MftfLogger ($ className );
66
72
$ logger ->pushHandler (new StreamHandler ($ this ->getLoggingPath ()));
67
- $ this ->loggers [$ clazz ] = $ logger ;
73
+ $ this ->loggers [$ className ] = $ logger ;
68
74
}
69
75
70
- return $ this ->loggers [$ clazz ];
76
+ return $ this ->loggers [$ className ];
71
77
}
72
78
73
79
/**
74
80
* Function which returns a static path to the the log file.
75
81
*
76
82
* @return string
77
83
*/
78
- public function getLoggingPath ()
84
+ public function getLoggingPath (): string
79
85
{
80
86
return TESTS_BP . DIRECTORY_SEPARATOR . "mftf.log " ;
81
87
}
0 commit comments