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.

Code Duplication    Length = 87-87 lines in 2 locations

app/Transformers/Admin/NodeTransformer.php 1 location

@@ 31-117 (lines=87) @@
28
use Pterodactyl\Models\Node;
29
use League\Fractal\TransformerAbstract;
30
31
class NodeTransformer extends TransformerAbstract
32
{
33
    /**
34
     * List of resources that can be included.
35
     *
36
     * @var array
37
     */
38
    protected $availableIncludes = [
39
        'allocations',
40
        'location',
41
        'servers',
42
    ];
43
44
    /**
45
     * The Illuminate Request object if provided.
46
     *
47
     * @var \Illuminate\Http\Request|bool
48
     */
49
    protected $request;
50
51
    /**
52
     * Setup request object for transformer.
53
     *
54
     * @param  \Illuminate\Http\Request|bool  $request
55
     * @return void
56
     */
57
    public function __construct($request = false)
58
    {
59
        if (! $request instanceof Request && $request !== false) {
60
            throw new DisplayException('Request passed to constructor must be of type Request or false.');
61
        }
62
63
        $this->request = $request;
64
    }
65
66
    /**
67
     * Return a generic transformed pack array.
68
     *
69
     * @return array
70
     */
71
    public function transform(Node $node)
72
    {
73
        return $node->toArray();
74
    }
75
76
    /**
77
     * Return the nodes associated with this location.
78
     *
79
     * @return \Leauge\Fractal\Resource\Collection
80
     */
81
    public function includeAllocations(Node $node)
82
    {
83
        if ($this->request && ! $this->request->apiKeyHasPermission('node-view')) {
84
            return;
85
        }
86
87
        return $this->collection($node->allocations, new AllocationTransformer($this->request), 'allocation');
88
    }
89
90
    /**
91
     * Return the nodes associated with this location.
92
     *
93
     * @return \Leauge\Fractal\Resource\Item
94
     */
95
    public function includeLocation(Node $node)
96
    {
97
        if ($this->request && ! $this->request->apiKeyHasPermission('location-list')) {
98
            return;
99
        }
100
101
        return $this->item($node->location, new LocationTransformer($this->request), 'location');
102
    }
103
104
    /**
105
     * Return the nodes associated with this location.
106
     *
107
     * @return \Leauge\Fractal\Resource\Collection
108
     */
109
    public function includeServers(Node $node)
110
    {
111
        if ($this->request && ! $this->request->apiKeyHasPermission('server-list')) {
112
            return;
113
        }
114
115
        return $this->collection($node->servers, new ServerTransformer($this->request), 'server');
116
    }
117
}
118

app/Transformers/Admin/ServiceTransformer.php 1 location

@@ 31-117 (lines=87) @@
28
use Pterodactyl\Models\Service;
29
use League\Fractal\TransformerAbstract;
30
31
class ServiceTransformer extends TransformerAbstract
32
{
33
    /**
34
     * List of resources that can be included.
35
     *
36
     * @var array
37
     */
38
    protected $availableIncludes = [
39
        'options',
40
        'servers',
41
        'packs',
42
    ];
43
44
    /**
45
     * The Illuminate Request object if provided.
46
     *
47
     * @var \Illuminate\Http\Request|bool
48
     */
49
    protected $request;
50
51
    /**
52
     * Setup request object for transformer.
53
     *
54
     * @param  \Illuminate\Http\Request|bool  $request
55
     * @return void
56
     */
57
    public function __construct($request = false)
58
    {
59
        if (! $request instanceof Request && $request !== false) {
60
            throw new DisplayException('Request passed to constructor must be of type Request or false.');
61
        }
62
63
        $this->request = $request;
64
    }
65
66
    /**
67
     * Return a generic transformed service array.
68
     *
69
     * @return array
70
     */
71
    public function transform(Service $service)
72
    {
73
        return $service->toArray();
74
    }
75
76
    /**
77
     * Return the the service options.
78
     *
79
     * @return \Leauge\Fractal\Resource\Collection
80
     */
81
    public function includeOptions(Service $service)
82
    {
83
        if ($this->request && ! $this->request->apiKeyHasPermission('option-list')) {
84
            return;
85
        }
86
87
        return $this->collection($service->options, new OptionTransformer($this->request), 'option');
88
    }
89
90
    /**
91
     * Return the servers associated with this service.
92
     *
93
     * @return \Leauge\Fractal\Resource\Collection
94
     */
95
    public function includeServers(Service $service)
96
    {
97
        if ($this->request && ! $this->request->apiKeyHasPermission('server-list')) {
98
            return;
99
        }
100
101
        return $this->collection($service->servers, new ServerTransformer($this->request), 'server');
102
    }
103
104
    /**
105
     * Return the packs associated with this service.
106
     *
107
     * @return \Leauge\Fractal\Resource\Collection
108
     */
109
    public function includePacks(Service $service)
110
    {
111
        if ($this->request && ! $this->request->apiKeyHasPermission('pack-list')) {
112
            return;
113
        }
114
115
        return $this->collection($service->packs, new PackTransformer($this->request), 'pack');
116
    }
117
}
118