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 ( 57a888...65f9e3 )
by Dane
16:31 queued 13:22
created

Pack   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 94
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 3

Importance

Changes 0
Metric Value
wmc 4
lcom 0
cbo 3
dl 0
loc 94
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A files() 0 16 2
A option() 0 4 1
A servers() 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\Models;
26
27
use File;
28
use Storage;
29
use Illuminate\Database\Eloquent\Model;
30
use Nicolaslopezj\Searchable\SearchableTrait;
31
32
class Pack extends Model
33
{
34
    use SearchableTrait;
35
36
    /**
37
     * The table associated with the model.
38
     *
39
     * @var string
40
     */
41
    protected $table = 'packs';
42
43
    /**
44
     * Fields that are mass assignable.
45
     *
46
     * @var array
47
     */
48
    protected $fillable = [
49
        'option_id', 'name', 'version', 'description', 'selectable', 'visible', 'locked',
50
    ];
51
52
    /**
53
     * Cast values to correct type.
54
     *
55
     * @var array
56
     */
57
    protected $casts = [
58
        'option_id' => 'integer',
59
        'selectable' => 'boolean',
60
        'visible' => 'boolean',
61
        'locked' => 'boolean',
62
    ];
63
64
    /**
65
     * Parameters for search querying.
66
     *
67
     * @var array
68
     */
69
    protected $searchable = [
70
        'columns' => [
71
            'packs.name' => 10,
72
            'packs.uuid' => 8,
73
            'service_options.name' => 6,
74
            'service_options.tag' => 5,
75
            'service_options.docker_image' => 5,
76
            'packs.version' => 2,
77
        ],
78
        'joins' => [
79
            'service_options' => ['packs.option_id', 'service_options.id'],
80
        ],
81
    ];
82
83
    /**
84
     * Returns all of the archived files for a given pack.
85
     *
86
     * @param  bool   $collection
87
     * @return \Illuminate\Support\Collection|object
88
     */
89
    public function files($collection = false)
90
    {
91
        $files = collect(Storage::files('packs/' . $this->uuid));
0 ignored issues
show
Documentation introduced by
The property uuid does not exist on object<Pterodactyl\Models\Pack>. Since you implemented __get, maybe consider adding a @property annotation.

Since your code implements the magic getter _get, this function will be called for any read access on an undefined variable. You can add the @property annotation to your class or interface to document the existence of this variable.

<?php

/**
 * @property int $x
 * @property int $y
 * @property string $text
 */
class MyLabel
{
    private $properties;

    private $allowedProperties = array('x', 'y', 'text');

    public function __get($name)
    {
        if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
            return $properties[$name];
        } else {
            return null;
        }
    }

    public function __set($name, $value)
    {
        if (in_array($name, $this->allowedProperties)) {
            $properties[$name] = $value;
        } else {
            throw new \LogicException("Property $name is not defined.");
        }
    }

}

If the property has read access only, you can use the @property-read annotation instead.

Of course, you may also just have mistyped another name, in which case you should fix the error.

See also the PhpDoc documentation for @property.

Loading history...
Bug introduced by
The method files() does not seem to exist on object<Illuminate\Contracts\Filesystem\Factory>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
92
93
        $files = $files->map(function ($item) {
94
            $path = storage_path('app/' . $item);
95
96
            return (object) [
97
                'name' => basename($item),
98
                'hash' => sha1_file($path),
99
                'size' => File::humanReadableSize($path),
100
            ];
101
        });
102
103
        return ($collection) ? $files : (object) $files->all();
104
    }
105
106
    /**
107
     * Gets option associated with a service pack.
108
     *
109
     * @return \Illuminate\Database\Eloquent\Relations\BelongsTo
110
     */
111
    public function option()
112
    {
113
        return $this->belongsTo(ServiceOption::class);
114
    }
115
116
    /**
117
     * Gets servers associated with a pack.
118
     *
119
     * @return \Illuminate\Database\Eloquent\Relations\HasMany
120
     */
121
    public function servers()
122
    {
123
        return $this->hasMany(Server::class);
124
    }
125
}
126