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.

SettingsController::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 2
nc 1
nop 1
dl 0
loc 4
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace App\Http\Controllers;
4
5
use App\Http\Requests\SettingsRequest;
6
use App\Services\VersionInfoService;
7
use Auth;
8
use Tremby\LaravelGitVersion\GitVersionHelper;
9
10
class SettingsController extends Controller
11
{
12
    /**
13
     * @var VersionInfoService
14
     */
15
    private $versionInfoService;
16
17
    /**
18
     * SettingController constructor.
19
     *
20
     * @param VersionInfoService $versionInfoService
21
     */
22
    public function __construct(VersionInfoService $versionInfoService)
23
    {
24
        $this->versionInfoService = $versionInfoService;
25
    }
26
27
    /**
28
     * @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
29
     */
30
    public function index()
31
    {
32
        $packages = $this->versionInfoService->packageInfo();
33
        $version = GitVersionHelper::getVersion();
34
        $apiVersion = \App\Services\Mmex\MmexConstants::$api_version;
35
        $user = Auth::user();
36
        $authGuid = $user->mmex_guid ?? mmex_guid();
37
        $userLocale = $user->locale;
38
        $disableStatus = $user->disable_status;
39
        $useDatepicker = $user->use_datepicker;
40
41
        return view('setting.index', compact('packages', 'version', 'userLocale', 'apiVersion', 'authGuid', 'disableStatus', 'useDatepicker'));
42
    }
43
44
    /**
45
     * @param SettingsRequest $request
46
     *
47
     * @return \Illuminate\Http\RedirectResponse
48
     */
49
    public function update(SettingsRequest $request)
50
    {
51
        $user = Auth::user();
52
53
        $user->locale = $request->user_locale;
0 ignored issues
show
Bug introduced by
The property user_locale does not seem to exist. Did you mean locale?

An attempt at access to an undefined property has been detected. This may either be a typographical error or the property has been renamed but there are still references to its old name.

If you really want to allow access to undefined properties, you can define magic methods to allow access. See the php core documentation on Overloading.

Loading history...
54
        $user->mmex_guid = $request->mmex_guid;
0 ignored issues
show
Bug introduced by
The property mmex_guid does not seem to exist in App\Http\Requests\SettingsRequest.

An attempt at access to an undefined property has been detected. This may either be a typographical error or the property has been renamed but there are still references to its old name.

If you really want to allow access to undefined properties, you can define magic methods to allow access. See the php core documentation on Overloading.

Loading history...
55
        $user->disable_status = $request->disable_status == 'true' ?? false;
0 ignored issues
show
Documentation introduced by
The property disable_status does not exist on object<App\Http\Requests\SettingsRequest>. 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...
56
        $user->use_datepicker = $request->use_datepicker == 'true' ?? false;
0 ignored issues
show
Documentation introduced by
The property use_datepicker does not exist on object<App\Http\Requests\SettingsRequest>. 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...
57
58
        $user->save();
59
60
        return back()->with('status', __('mmex.updated'));
61
    }
62
}
63