File Logger.php
has 355 lines of code (exceeds 250 allowed). Consider refactoring. Open
<?php
declare(strict_types=1);
namespace Async;
Logger
has 29 functions (exceeds 20 allowed). Consider refactoring. Open
final class Logger extends AsyncLogger implements AsyncLoggerInterface
{
private static $levels = [
self::DEBUG => LogLevel::DEBUG,
self::INFO => LogLevel::INFO,
Function interpolate
has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring. Open
private static function interpolate($string, array $vars)
{
if (!\preg_match_all("~\{([\w\.]+)\}~", $string, $matches, \PREG_SET_ORDER)) {
return $string;
}
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Function setWriter
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
public function setWriter(callable $writer = null, $levels = self::ALL, $interval = 1, callable $formatter = null)
{
if (empty($formatter)) {
$formatter = $this->defaultFormatter;
}
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Method setWriter
has 29 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function setWriter(callable $writer = null, $levels = self::ALL, $interval = 1, callable $formatter = null)
{
if (empty($formatter)) {
$formatter = $this->defaultFormatter;
}
Method interpolate
has 28 lines of code (exceeds 25 allowed). Consider refactoring. Open
private static function interpolate($string, array $vars)
{
if (!\preg_match_all("~\{([\w\.]+)\}~", $string, $matches, \PREG_SET_ORDER)) {
return $string;
}
Method mailWriter
has 6 arguments (exceeds 4 allowed). Consider refactoring. Open
$to,
$subject = null,
array $headers = [],
$levels = self::ALL,
$interval = 1,
Function log
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
public function log($level, $message, array $context = [])
{
if (false === $level = \array_search($level, self::$levels, true)) {
yield $this->close();
throw new InvalidArgumentException(\sprintf("Unknown logger(%s) level name: '%s'", $this->name, $level));
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"