stk2k/eventstream

View on GitHub

Showing 6 of 6 total issues

Function emit has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring.
Open

    public function emit(Event $event)
    {
        if (is_array($this->listeners)){
            foreach($this->listeners as $event_key => $listers_of_event){
                if ($event_key === $event->getName()){
Severity: Minor
Found in src/emitter/WildCardEventEmitter.php - About 2 hrs to fix

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 getRegExp has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
Open

    public function getRegExp($event_key)
    {
        $pos = strpos($event_key,'*');
        if ($pos === false){
            return null;
Severity: Minor
Found in src/emitter/WildCardEventEmitter.php - About 1 hr to fix

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 getRegExp has 29 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    public function getRegExp($event_key)
    {
        $pos = strpos($event_key,'*');
        if ($pos === false){
            return null;
Severity: Minor
Found in src/emitter/WildCardEventEmitter.php - About 1 hr to fix

    Function emit has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
    Open

        public function emit(Event $event)
        {
            if (is_array($this->listeners)){
                foreach($this->listeners as $reg_exp => $listers_of_event){
                    if (preg_match($reg_exp,$event->getName())){
    Severity: Minor
    Found in src/emitter/RegularExpressionEventEmitter.php - About 1 hr to fix

    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 unlisten has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
    Open

        public function unlisten(string $event = null, callable $listener = null)
        {
            // if event is null, remove all listeners
            if ($event=== null){
                $this->listeners = null;
    Severity: Minor
    Found in src/emitter/SimpleEventEmitter.php - About 55 mins to fix

    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 flush has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

        public function flush(){
            if (!$this->source || !$this->emitter){
                return $this;
            }
            while($e = $this->source->next()){
    Severity: Minor
    Found in src/EventChannel.php - About 25 mins to fix

    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

    Severity
    Category
    Status
    Source
    Language