BlueTeamManager   A
last analyzed

Complexity

Total Complexity 9

Size/Duplication

Total Lines 53
Duplicated Lines 100 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

Changes 0
Metric Value
wmc 9
lcom 1
cbo 2
dl 53
loc 53
rs 10
c 0
b 0
f 0

6 Methods

Rating   Name   Duplication   Size   Complexity  
A addList() 6 6 2
A removeList() 6 6 2
A isJoined() 4 4 2
A getList() 4 4 1
A getListCount() 4 4 1
A ClearList() 4 4 1

How to fix   Duplicated Code   

Duplicated Code

Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.

Common duplication problems, and corresponding solutions are:

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\Player;
12
use VectorNetworkProject\TheMix\game\corepvp\TeamManager;
13
14 View Code Duplication
class BlueTeamManager extends TeamManager
0 ignored issues
show
Duplication introduced by
This class seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
Coding Style introduced by
BlueTeamManager 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...
15
{
16
    /** @var array $list */
17
    private static $list = [];
18
19
    public static function addList(Player $player): void
20
    {
21
        if (!self::isJoined($player)) {
22
            self::$list[$player->getName()] = $player->getName();
23
        }
24
    }
25
26
    /**
27
     * @param Player $player
28
     */
29
    public static function removeList(Player $player): void
30
    {
31
        if (self::isJoined($player)) {
32
            unset(self::$list[$player->getName()]);
33
        }
34
    }
35
36
    /**
37
     * @param Player $player
38
     *
39
     * @return bool
40
     */
41
    public static function isJoined(Player $player): bool
42
    {
43
        return isset(self::$list[$player->getName()]) ? true : false;
44
    }
45
46
    /**
47
     * @return array
48
     */
49
    public static function getList(): array
50
    {
51
        return self::$list;
52
    }
53
54
    /**
55
     * @return int
56
     */
57
    public static function getListCount(): int
58
    {
59
        return count(self::$list);
60
    }
61
62
    public static function ClearList(): void
0 ignored issues
show
Coding Style introduced by
function ClearList() does not seem to conform to the naming convention (^(?:[a-z]|__)[a-zA-Z0-9]*$).

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...
63
    {
64
        self::$list = [];
65
    }
66
}
67