PhaseManager::addPhase()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 11

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 11
rs 9.9
c 0
b 0
f 0
cc 2
nc 2
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;
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