Function doEventsRegister
has a Cognitive Complexity of 60 (exceeds 5 allowed). Consider refactoring. Open
private function doEventsRegister(Container $container, Definition $eventDispatcher, string $listenerTag, array $eventSubscribers)
{
[$subscriberTag, $eventSubscribers] = $eventSubscribers;
foreach ($container->tagged($listenerTag) as $id => $event) {
- 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 doEventsRegister
has 73 lines of code (exceeds 25 allowed). Consider refactoring. Open
private function doEventsRegister(Container $container, Definition $eventDispatcher, string $listenerTag, array $eventSubscribers)
{
[$subscriberTag, $eventSubscribers] = $eventSubscribers;
foreach ($container->tagged($listenerTag) as $id => $event) {
Consider simplifying this complex logical expression. Open
if (
null === ($class = $container->definition($id)->getEntity())
|| !($r = new \ReflectionClass($class))
|| !$r->hasMethod($method)
|| 1 > ($m = $r->getMethod($method))->getNumberOfParameters()
Function register
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
public function register(Container $container, array $configs = []): void
{
if (isset($configs['dispatcher_class'])) {
$dispatcher = $configs['dispatcher_class'];
- 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 boot
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
public function boot(Container $container): void
{
if ($container->has('events.dispatcher')) {
if ($container->shared('events.dispatcher')) {
$container->removeShared('events.dispatcher');
- 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"