Skip to content

Commit 96a63c7

Browse files
committed
Cleanup for LoggingUtil.
1 parent 9e0160e commit 96a63c7

File tree

1 file changed

+23
-17
lines changed

1 file changed

+23
-17
lines changed

src/Magento/FunctionalTestingFramework/Util/Logger/LoggingUtil.php

Lines changed: 23 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -19,63 +19,69 @@ class LoggingUtil
1919
private $loggers = [];
2020

2121
/**
22-
* Singleton LogginUtil Instance
22+
* Singleton LoggingUtil Instance
2323
*
2424
* @var LoggingUtil
2525
*/
26-
private static $INSTANCE;
26+
private static $instance;
2727

2828
/**
2929
* Singleton accessor for instance variable
3030
*
3131
* @return LoggingUtil
3232
*/
33-
public static function getInstance()
33+
public static function getInstance(): LoggingUtil
3434
{
35-
if (self::$INSTANCE == null) {
36-
self::$INSTANCE = new LoggingUtil();
35+
if (self::$instance === null) {
36+
self::$instance = new LoggingUtil();
3737
}
3838

39-
return self::$INSTANCE;
39+
return self::$instance;
4040
}
4141

4242
/**
43-
* Constructor for Logging Util
43+
* Avoids instantiation of LoggingUtil by new.
4444
*/
4545
private function __construct()
4646
{
47-
// private constructor
47+
}
48+
49+
/**
50+
* Avoids instantiation of LoggingUtil by clone.
51+
*/
52+
private function __clone()
53+
{
4854
}
4955

5056
/**
5157
* Creates a new logger instances based on class name if it does not exist. If logger instance already exists, the
5258
* existing instance is simply returned.
5359
*
54-
* @param string $clazz
60+
* @param string $className
5561
* @return MftfLogger
5662
* @throws \Exception
5763
*/
58-
public function getLogger($clazz)
64+
public function getLogger($className): MftfLogger
5965
{
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");
6268
}
6369

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);
6672
$logger->pushHandler(new StreamHandler($this->getLoggingPath()));
67-
$this->loggers[$clazz] = $logger;
73+
$this->loggers[$className] = $logger;
6874
}
6975

70-
return $this->loggers[$clazz];
76+
return $this->loggers[$className];
7177
}
7278

7379
/**
7480
* Function which returns a static path to the the log file.
7581
*
7682
* @return string
7783
*/
78-
public function getLoggingPath()
84+
public function getLoggingPath(): string
7985
{
8086
return TESTS_BP . DIRECTORY_SEPARATOR . "mftf.log";
8187
}

0 commit comments

Comments
 (0)