PhaseManager   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 39
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

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

3 Methods

Rating   Name   Duplication   Size   Complexity  
A setPhase() 0 4 1
A addPhase() 0 11 2
A getPhase() 0 4 1
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;
10
11
use VectorNetworkProject\TheMix\game\event\game\PhaseUpdateEvent;
12
use VectorNetworkProject\TheMix\task\PhaseTask;
13
14
class PhaseManager
0 ignored issues
show
Coding Style introduced by
PhaseManager 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 int */
17
    public const MAX_PHASE = 3;
18
19
    /** @var int $phase */
20
    private static $phase = 1;
21
22
    /**
23
     * @param int $phase
24
     */
25
    public static function setPhase(int $phase): void
26
    {
27
        self::$phase = $phase;
28
    }
29
30
    /**
31
     * @throws \ReflectionException
32
     */
33
    public static function addPhase(): void
34
    {
35
        $event = new PhaseUpdateEvent(self::getPhase() + 1);
36
        $event->call();
37
        if (!$event->isCancelled()) {
38
            self::$phase++;
39
            PhaseTask::setTime();
40
        } else {
41
            PhaseTask::setTime();
42
        }
43
    }
44
45
    /**
46
     * @return int
47
     */
48
    public static function getPhase(): int
49
    {
50
        return self::$phase;
51
    }
52
}
53