BlueSpawnManager::getRandomPosition()   A
last analyzed

Complexity

Conditions 3
Paths 3

Size

Total Lines 16

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 16
rs 9.7333
c 0
b 0
f 0
cc 3
nc 3
nop 0
1
<?php
2
/**
3
 * Copyright (c) 2018 VectorNetworkProject. All rights reserved. MIT license.
4
 *
5
 * GitHub: https://github.com/VectorNetworkProject/TheMix
6
 * Website: https://www.vector-network.tk
7
 */
8
9
namespace VectorNetworkProject\TheMix\game\corepvp\blue;
10
11
use pocketmine\level\Position;
12
use pocketmine\Server;
13
use VectorNetworkProject\TheMix\game\corepvp\SpawnManager;
14
use VectorNetworkProject\TheMix\game\DefaultConfig;
15
16
class BlueSpawnManager extends SpawnManager
0 ignored issues
show
Coding Style introduced by
BlueSpawnManager does not seem to conform to the naming convention (Utils?$).

This check examines a number of code elements and verifies that they conform to the given naming conventions.

You can set conventions for local variables, abstract classes, utility classes, constant, properties, methods, parameters, interfaces, classes, exceptions and special methods.

Loading history...
17
{
18
    /**
19
     * @return Position|null
20
     */
21
    public static function getRandomPosition(): ?Position
22
    {
23
        switch (mt_rand(1, 2)) {
24
            case 1:
25
                $spawn = BlueConfig::getSpawn1();
26
27
                return new Position($spawn['x'], $spawn['y'], $spawn['z'], Server::getInstance()->getLevelByName(DefaultConfig::getStageLevelName()));
28
                break;
0 ignored issues
show
Unused Code introduced by
break is not strictly necessary here and could be removed.

The break statement is not necessary if it is preceded for example by a return statement:

switch ($x) {
    case 1:
        return 'foo';
        break; // This break is not necessary and can be left off.
}

If you would like to keep this construct to be consistent with other case statements, you can safely mark this issue as a false-positive.

Loading history...
29
            case 2:
30
                $spawn = BlueConfig::getSpawn2();
31
32
                return new Position($spawn['x'], $spawn['y'], $spawn['z'], Server::getInstance()->getLevelByName(DefaultConfig::getStageLevelName()));
33
                break;
0 ignored issues
show
Unused Code introduced by
break is not strictly necessary here and could be removed.

The break statement is not necessary if it is preceded for example by a return statement:

switch ($x) {
    case 1:
        return 'foo';
        break; // This break is not necessary and can be left off.
}

If you would like to keep this construct to be consistent with other case statements, you can safely mark this issue as a false-positive.

Loading history...
34
            default: return null;
35
        }
36
    }
37
}
38