From 42939725debdd8261b66f0818385752cd0c72ad0 Mon Sep 17 00:00:00 2001
From: Paul Water
Date: Wed, 25 Jan 2023 11:52:11 +0100
Subject: [PATCH] Code enhancements.
---
src/StratumStyle.php | 75 +++++++++++++++++++++++++++++---------------
1 file changed, 50 insertions(+), 25 deletions(-)
diff --git a/src/StratumStyle.php b/src/StratumStyle.php
index f77b6b0..1a769c0 100644
--- a/src/StratumStyle.php
+++ b/src/StratumStyle.php
@@ -39,62 +39,87 @@ public function __construct(InputInterface $input, OutputInterface $output)
}
//--------------------------------------------------------------------------------------------------------------------
- public function logDebug()
+ /**
+ * Logs a message according to a format string at verbosity level OutputInterface::VERBOSITY_NORMAL.
+ *
+ * @param string $format The format string, see sprintf.
+ * @param mixed ...$values The values.
+ *
+ * @return void
+ */
+ public function logDebug(string $format, mixed ...$values): void
{
if ($this->getVerbosity()>=OutputInterface::VERBOSITY_DEBUG)
{
- $args = func_get_args();
- $format = array_shift($args);
-
- $this->writeln(vsprintf(''.$format.'', $args));
+ $this->writeln(vsprintf(''.$format.'', $values));
}
}
//--------------------------------------------------------------------------------------------------------------------
- public function logInfo()
+ /**
+ * Logs a message according to a format string at verbosity level OutputInterface::VERBOSITY_NORMAL.
+ *
+ * @param string $format The format string, see sprintf.
+ * @param mixed ...$values The values.
+ *
+ * @return void
+ */
+ public function logInfo(string $format, mixed ...$values): void
{
if ($this->getVerbosity()>=OutputInterface::VERBOSITY_NORMAL)
{
- $args = func_get_args();
- $format = array_shift($args);
-
- $this->writeln(vsprintf(''.$format.'', $args));
+ $this->writeln(vsprintf(''.$format.'', $values));
}
}
//--------------------------------------------------------------------------------------------------------------------
- public function logNote()
+ /**
+ * Logs a message according to a format string at verbosity level OutputInterface::VERBOSITY_NORMAL.
+ *
+ * @param string $format The format string, see sprintf.
+ * @param mixed ...$values The values.
+ *
+ * @return void
+ */
+ public function logNote(string $format, mixed ...$values): void
{
if ($this->getVerbosity()>=OutputInterface::VERBOSITY_NORMAL)
{
- $args = func_get_args();
- $format = array_shift($args);
-
- $this->writeln(' ! [NOTE] '.vsprintf($format, $args).'');
+ $this->writeln(' ! [NOTE] '.vsprintf($format, $values).'');
}
}
//--------------------------------------------------------------------------------------------------------------------
- public function logVerbose()
+ /**
+ * Logs a message according to a format string at verbosity level OutputInterface::VERBOSITY_VERBOSE.
+ *
+ * @param string $format The format string, see sprintf.
+ * @param mixed ...$values The values.
+ *
+ * @return void
+ */
+ public function logVerbose(string $format, mixed ...$values): void
{
if ($this->getVerbosity()>=OutputInterface::VERBOSITY_VERBOSE)
{
- $args = func_get_args();
- $format = array_shift($args);
-
- $this->writeln(vsprintf(''.$format.'', $args));
+ $this->writeln(vsprintf(''.$format.'', $values));
}
}
//--------------------------------------------------------------------------------------------------------------------
- public function logVeryVerbose()
+ /**
+ * Logs a message according to a format string at verbosity level OutputInterface::VERBOSITY_VERY_VERBOSE.
+ *
+ * @param string $format The format string, see sprintf.
+ * @param mixed ...$values The values.
+ *
+ * @return void
+ */
+ public function logVeryVerbose(string $format, mixed ...$values): void
{
if ($this->getVerbosity()>=OutputInterface::VERBOSITY_VERY_VERBOSE)
{
- $args = func_get_args();
- $format = array_shift($args);
-
- $this->writeln(vsprintf(''.$format.'', $args));
+ $this->writeln(vsprintf(''.$format.'', $values));
}
}