Client::gm()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
cc 1
eloc 2
nc 1
nop 0
dl 0
loc 4
ccs 2
cts 2
cp 1
crap 1
rs 10
c 0
b 0
f 0
1
<?php namespace FreedomCore\TrinityCore\Console;
2
3
use FreedomCore\TrinityCore\Console\Abstracts\BaseClient;
4
use FreedomCore\TrinityCore\Console\Commands\Account;
5
use FreedomCore\TrinityCore\Console\Commands\BNetAccount;
6
use FreedomCore\TrinityCore\Console\Commands\GM;
7
use FreedomCore\TrinityCore\Console\Commands\Guild;
8
use FreedomCore\TrinityCore\Console\Commands\LFG;
9
use FreedomCore\TrinityCore\Console\Commands\Character;
10
use FreedomCore\TrinityCore\Console\Commands\Reset;
11
use FreedomCore\TrinityCore\Console\Commands\Send;
12
use FreedomCore\TrinityCore\Console\Commands\Server;
13
14
/**
15
 * Class Client
16
 * @package FreedomCore\TrinityCore\Console
17
 */
18
class Client extends BaseClient
19
{
20
21
    /**
22
     * Client constructor.
23
     * @param string $username Username used to connect to the server
24
     * @param string $password Password used to connect to the server
25
     * @param boolean $createNow Should the connection be created as soon as possible
26
     * @throws \Exception
27
     */
28 38
    public function __construct(string $username, string $password, bool $createNow = true)
29
    {
30 38
        parent::__construct($username, $password, $createNow);
31 38
    }
32
33
    /**
34
     * Get Account Command Instance
35
     * @return Account
36
     */
37 2
    public function account() : Account
38
    {
39 2
        return (new Account($this->client));
0 ignored issues
show
Bug introduced by
It seems like $this->client can be null; however, __construct() does not accept null, maybe add an additional type check?

Unless you are absolutely sure that the expression can never be null because of other conditions, we strongly recommend to add an additional type check to your code:

/** @return stdClass|null */
function mayReturnNull() { }

function doesNotAcceptNull(stdClass $x) { }

// With potential error.
function withoutCheck() {
    $x = mayReturnNull();
    doesNotAcceptNull($x); // Potential error here.
}

// Safe - Alternative 1
function withCheck1() {
    $x = mayReturnNull();
    if ( ! $x instanceof stdClass) {
        throw new \LogicException('$x must be defined.');
    }
    doesNotAcceptNull($x);
}

// Safe - Alternative 2
function withCheck2() {
    $x = mayReturnNull();
    if ($x instanceof stdClass) {
        doesNotAcceptNull($x);
    }
}
Loading history...
40
    }
41
42
    /**
43
     * Get Bnet Command Instance
44
     * @return BNetAccount
45
     */
46 2
    public function bnet() : BNetAccount
47
    {
48 2
        return (new BNetAccount($this->client));
0 ignored issues
show
Bug introduced by
It seems like $this->client can be null; however, __construct() does not accept null, maybe add an additional type check?

Unless you are absolutely sure that the expression can never be null because of other conditions, we strongly recommend to add an additional type check to your code:

/** @return stdClass|null */
function mayReturnNull() { }

function doesNotAcceptNull(stdClass $x) { }

// With potential error.
function withoutCheck() {
    $x = mayReturnNull();
    doesNotAcceptNull($x); // Potential error here.
}

// Safe - Alternative 1
function withCheck1() {
    $x = mayReturnNull();
    if ( ! $x instanceof stdClass) {
        throw new \LogicException('$x must be defined.');
    }
    doesNotAcceptNull($x);
}

// Safe - Alternative 2
function withCheck2() {
    $x = mayReturnNull();
    if ($x instanceof stdClass) {
        doesNotAcceptNull($x);
    }
}
Loading history...
49
    }
50
51
    /**
52
     * Get Character Command Instance
53
     * @return Character
54
     */
55 2
    public function character() : Character
56
    {
57 2
        return (new Character($this->client));
0 ignored issues
show
Bug introduced by
It seems like $this->client can be null; however, __construct() does not accept null, maybe add an additional type check?

Unless you are absolutely sure that the expression can never be null because of other conditions, we strongly recommend to add an additional type check to your code:

/** @return stdClass|null */
function mayReturnNull() { }

function doesNotAcceptNull(stdClass $x) { }

// With potential error.
function withoutCheck() {
    $x = mayReturnNull();
    doesNotAcceptNull($x); // Potential error here.
}

// Safe - Alternative 1
function withCheck1() {
    $x = mayReturnNull();
    if ( ! $x instanceof stdClass) {
        throw new \LogicException('$x must be defined.');
    }
    doesNotAcceptNull($x);
}

// Safe - Alternative 2
function withCheck2() {
    $x = mayReturnNull();
    if ($x instanceof stdClass) {
        doesNotAcceptNull($x);
    }
}
Loading history...
58
    }
59
60
    /**
61
     * Get GM Command Instance
62
     * @return GM
63
     */
64 2
    public function gm() : GM
65
    {
66 2
        return (new GM($this->client));
0 ignored issues
show
Bug introduced by
It seems like $this->client can be null; however, __construct() does not accept null, maybe add an additional type check?

Unless you are absolutely sure that the expression can never be null because of other conditions, we strongly recommend to add an additional type check to your code:

/** @return stdClass|null */
function mayReturnNull() { }

function doesNotAcceptNull(stdClass $x) { }

// With potential error.
function withoutCheck() {
    $x = mayReturnNull();
    doesNotAcceptNull($x); // Potential error here.
}

// Safe - Alternative 1
function withCheck1() {
    $x = mayReturnNull();
    if ( ! $x instanceof stdClass) {
        throw new \LogicException('$x must be defined.');
    }
    doesNotAcceptNull($x);
}

// Safe - Alternative 2
function withCheck2() {
    $x = mayReturnNull();
    if ($x instanceof stdClass) {
        doesNotAcceptNull($x);
    }
}
Loading history...
67
    }
68
69
    /**
70
     * Get Guild Command Instance
71
     * @return Guild
72
     */
73 2
    public function guild() : Guild
74
    {
75 2
        return (new Guild($this->client));
0 ignored issues
show
Bug introduced by
It seems like $this->client can be null; however, __construct() does not accept null, maybe add an additional type check?

Unless you are absolutely sure that the expression can never be null because of other conditions, we strongly recommend to add an additional type check to your code:

/** @return stdClass|null */
function mayReturnNull() { }

function doesNotAcceptNull(stdClass $x) { }

// With potential error.
function withoutCheck() {
    $x = mayReturnNull();
    doesNotAcceptNull($x); // Potential error here.
}

// Safe - Alternative 1
function withCheck1() {
    $x = mayReturnNull();
    if ( ! $x instanceof stdClass) {
        throw new \LogicException('$x must be defined.');
    }
    doesNotAcceptNull($x);
}

// Safe - Alternative 2
function withCheck2() {
    $x = mayReturnNull();
    if ($x instanceof stdClass) {
        doesNotAcceptNull($x);
    }
}
Loading history...
76
    }
77
78
    /**
79
     * Get LFG Command Instance
80
     * @return LFG
81
     */
82 2
    public function lfg() : LFG
83
    {
84 2
        return (new LFG($this->client));
0 ignored issues
show
Bug introduced by
It seems like $this->client can be null; however, __construct() does not accept null, maybe add an additional type check?

Unless you are absolutely sure that the expression can never be null because of other conditions, we strongly recommend to add an additional type check to your code:

/** @return stdClass|null */
function mayReturnNull() { }

function doesNotAcceptNull(stdClass $x) { }

// With potential error.
function withoutCheck() {
    $x = mayReturnNull();
    doesNotAcceptNull($x); // Potential error here.
}

// Safe - Alternative 1
function withCheck1() {
    $x = mayReturnNull();
    if ( ! $x instanceof stdClass) {
        throw new \LogicException('$x must be defined.');
    }
    doesNotAcceptNull($x);
}

// Safe - Alternative 2
function withCheck2() {
    $x = mayReturnNull();
    if ($x instanceof stdClass) {
        doesNotAcceptNull($x);
    }
}
Loading history...
85
    }
86
87
    /**
88
     * Get Reset Command Instance
89
     * @return Reset
90
     */
91 2
    public function reset() : Reset
92
    {
93 2
        return (new Reset($this->client));
0 ignored issues
show
Bug introduced by
It seems like $this->client can be null; however, __construct() does not accept null, maybe add an additional type check?

Unless you are absolutely sure that the expression can never be null because of other conditions, we strongly recommend to add an additional type check to your code:

/** @return stdClass|null */
function mayReturnNull() { }

function doesNotAcceptNull(stdClass $x) { }

// With potential error.
function withoutCheck() {
    $x = mayReturnNull();
    doesNotAcceptNull($x); // Potential error here.
}

// Safe - Alternative 1
function withCheck1() {
    $x = mayReturnNull();
    if ( ! $x instanceof stdClass) {
        throw new \LogicException('$x must be defined.');
    }
    doesNotAcceptNull($x);
}

// Safe - Alternative 2
function withCheck2() {
    $x = mayReturnNull();
    if ($x instanceof stdClass) {
        doesNotAcceptNull($x);
    }
}
Loading history...
94
    }
95
96
    /**
97
     * Get Send Command Instance
98
     * @return Send
99
     */
100 2
    public function send() : Send
101
    {
102 2
        return (new Send($this->client));
0 ignored issues
show
Bug introduced by
It seems like $this->client can be null; however, __construct() does not accept null, maybe add an additional type check?

Unless you are absolutely sure that the expression can never be null because of other conditions, we strongly recommend to add an additional type check to your code:

/** @return stdClass|null */
function mayReturnNull() { }

function doesNotAcceptNull(stdClass $x) { }

// With potential error.
function withoutCheck() {
    $x = mayReturnNull();
    doesNotAcceptNull($x); // Potential error here.
}

// Safe - Alternative 1
function withCheck1() {
    $x = mayReturnNull();
    if ( ! $x instanceof stdClass) {
        throw new \LogicException('$x must be defined.');
    }
    doesNotAcceptNull($x);
}

// Safe - Alternative 2
function withCheck2() {
    $x = mayReturnNull();
    if ($x instanceof stdClass) {
        doesNotAcceptNull($x);
    }
}
Loading history...
103
    }
104
    
105
    /**
106
     * Get Server Command Instance
107
     * @return Server
108
     */
109 2
    public function server() : Server
110
    {
111 2
        return (new Server($this->client));
0 ignored issues
show
Bug introduced by
It seems like $this->client can be null; however, __construct() does not accept null, maybe add an additional type check?

Unless you are absolutely sure that the expression can never be null because of other conditions, we strongly recommend to add an additional type check to your code:

/** @return stdClass|null */
function mayReturnNull() { }

function doesNotAcceptNull(stdClass $x) { }

// With potential error.
function withoutCheck() {
    $x = mayReturnNull();
    doesNotAcceptNull($x); // Potential error here.
}

// Safe - Alternative 1
function withCheck1() {
    $x = mayReturnNull();
    if ( ! $x instanceof stdClass) {
        throw new \LogicException('$x must be defined.');
    }
    doesNotAcceptNull($x);
}

// Safe - Alternative 2
function withCheck2() {
    $x = mayReturnNull();
    if ($x instanceof stdClass) {
        doesNotAcceptNull($x);
    }
}
Loading history...
112
    }
113
}
114