GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.
Completed
Push — develop ( 10ee77...db168e )
by Dane
07:24 queued 04:36
created

ServerTransformer   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 71
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 5

Importance

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

4 Methods

Rating   Name   Duplication   Size   Complexity  
A transform() 0 18 1
A includeAllocations() 0 6 1
A includeSubusers() 0 6 1
A includeStats() 0 4 1
1
<?php
2
/**
3
 * Pterodactyl - Panel
4
 * Copyright (c) 2015 - 2017 Dane Everitt <[email protected]>.
5
 *
6
 * Permission is hereby granted, free of charge, to any person obtaining a copy
7
 * of this software and associated documentation files (the "Software"), to deal
8
 * in the Software without restriction, including without limitation the rights
9
 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10
 * copies of the Software, and to permit persons to whom the Software is
11
 * furnished to do so, subject to the following conditions:
12
 *
13
 * The above copyright notice and this permission notice shall be included in all
14
 * copies or substantial portions of the Software.
15
 *
16
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19
 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21
 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22
 * SOFTWARE.
23
 */
24
25
namespace Pterodactyl\Transformers\User;
26
27
use Pterodactyl\Models\Server;
28
use League\Fractal\TransformerAbstract;
29
30
class ServerTransformer extends TransformerAbstract
31
{
32
    /**
33
     * List of resources that can be included.
34
     *
35
     * @var array
36
     */
37
    protected $availableIncludes = [
38
        'allocations',
39
        'subusers',
40
        'stats',
41
    ];
42
43
    /**
44
     * Return a generic transformed server array.
45
     *
46
     * @return array
47
     */
48
    public function transform(Server $server)
49
    {
50
        return [
51
            'id' => $server->uuidShort,
52
            'uuid' => $server->uuid,
53
            'name' => $server->name,
54
            'description' => $server->description,
55
            'node' => $server->node->name,
56
            'limits' => [
57
                'memory' => $server->memory,
58
                'swap' => $server->swap,
59
                'disk' => $server->disk,
60
                'io' => $server->io,
61
                'cpu' => $server->cpu,
62
                'oom_disabled' => (bool) $server->oom_disabled,
63
            ],
64
        ];
65
    }
66
67
    /**
68
     * Return a generic array of allocations for this server.
69
     *
70
     * @return \Leauge\Fractal\Resource\Collection
71
     */
72
    public function includeAllocations(Server $server)
73
    {
74
        $allocations = $server->allocations;
75
76
        return $this->collection($allocations, new AllocationTransformer($server), 'allocation');
0 ignored issues
show
Documentation introduced by
new \Pterodactyl\Transfo...ionTransformer($server) is of type object<Pterodactyl\Trans...\AllocationTransformer>, but the function expects a callable.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
77
    }
78
79
    /**
80
     * Return a generic array of subusers for this server.
81
     *
82
     * @return \Leauge\Fractal\Resource\Collection
83
     */
84
    public function includeSubusers(Server $server)
85
    {
86
        $server->load('subusers.permissions', 'subusers.user');
87
88
        return $this->collection($server->subusers, new SubuserTransformer, 'subuser');
0 ignored issues
show
Documentation introduced by
new \Pterodactyl\Transfo...er\SubuserTransformer() is of type object<Pterodactyl\Trans...ser\SubuserTransformer>, but the function expects a callable.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
89
    }
90
91
    /**
92
     * Return a generic array of allocations for this server.
93
     *
94
     * @return \Leauge\Fractal\Resource\Item
95
     */
96
    public function includeStats(Server $server)
97
    {
98
        return $this->item($server->guzzleClient(), new StatsTransformer, 'stat');
0 ignored issues
show
Documentation introduced by
new \Pterodactyl\Transfo...User\StatsTransformer() is of type object<Pterodactyl\Trans...\User\StatsTransformer>, but the function expects a callable.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
99
    }
100
}
101