Draw   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 29
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 3

Importance

Changes 0
Metric Value
wmc 4
lcom 0
cbo 3
dl 0
loc 29
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A handle() 0 19 4
1
<?php
2
3
namespace App\Listeners\Tournament;
4
5
use App\Events\Tournament\AbstractTournamentDrawEvent;
6
use App\Jobs\Tournament\DrawKnockOut;
7
use App\Jobs\Tournament\DrawLeague;
8
use App\Tournament;
9
10
/**
11
 * Class Draw
12
 * @package App\Listeners\Tournament
13
 */
14
class Draw
15
{
16
    /**
17
     * Handle the event.
18
     *
19
     * @param  AbstractTournamentDrawEvent $event
20
     * @return void
21
     * @throws \RuntimeException
22
     */
23
    public function handle(AbstractTournamentDrawEvent $event)
24
    {
25
        $tournament = $event->tournament;
26
27
        switch ($tournament->type) {
0 ignored issues
show
Documentation introduced by
The property type does not exist on object<App\Tournament>. Since you implemented __get, maybe consider adding a @property annotation.

Since your code implements the magic getter _get, this function will be called for any read access on an undefined variable. You can add the @property annotation to your class or interface to document the existence of this variable.

<?php

/**
 * @property int $x
 * @property int $y
 * @property string $text
 */
class MyLabel
{
    private $properties;

    private $allowedProperties = array('x', 'y', 'text');

    public function __get($name)
    {
        if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
            return $properties[$name];
        } else {
            return null;
        }
    }

    public function __set($name, $value)
    {
        if (in_array($name, $this->allowedProperties)) {
            $properties[$name] = $value;
        } else {
            throw new \LogicException("Property $name is not defined.");
        }
    }

}

If the property has read access only, you can use the @property-read annotation instead.

Of course, you may also just have mistyped another name, in which case you should fix the error.

See also the PhpDoc documentation for @property.

Loading history...
28
            case Tournament::TYPE_LEAGUE:
29
                $job = new DrawLeague($tournament);
30
                $job->handle();
31
                break;
32
33
            case Tournament::TYPE_KNOCK_OUT:
34
                $job = new DrawKnockOut($tournament);
35
                $job->handle();
36
                break;
37
            case Tournament::TYPE_MULTISTAGE:
38
                throw new \RuntimeException('Not implemented');
39
                break;
0 ignored issues
show
Unused Code introduced by
break; does not seem to be reachable.

This check looks for unreachable code. It uses sophisticated control flow analysis techniques to find statements which will never be executed.

Unreachable code is most often the result of return, die or exit statements that have been added for debug purposes.

function fx() {
    try {
        doSomething();
        return true;
    }
    catch (\Exception $e) {
        return false;
    }

    return false;
}

In the above example, the last return false will never be executed, because a return statement has already been met in every possible execution path.

Loading history...
40
        }
41
    }
42
}
43