Issues (41)

app/Services/ApiService.php (6 issues)

1
<?php
2
/**
3
 * Created by PhpStorm.
4
 * User: me
5
 * Date: 17.06.17
6
 * Time: 21:34
7
 */
8
namespace TaskManager\Services;
9
10
use TaskManager\ApiKeys;
11
12
class ApiService
13
{
14
15
    protected $api;
16
    function __construct(\TaskManager\ApiKeys $api)
17
    {
18
    $this->api = $api;
19
    }
20
21
    public function generateKey($user_id=null)
0 ignored issues
show
The parameter $user_id is not used and could be removed. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unused  annotation

21
    public function generateKey(/** @scrutinizer ignore-unused */ $user_id=null)

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
22
    {
23
        $this->api->key = uniqid();
0 ignored issues
show
The property key does not seem to exist on TaskManager\ApiKeys. Are you sure there is no database migration missing?

Checks if undeclared accessed properties appear in database migrations and if the creating migration is correct.

Loading history...
24
        $this->api->active = true;
0 ignored issues
show
The property active does not seem to exist on TaskManager\ApiKeys. Are you sure there is no database migration missing?

Checks if undeclared accessed properties appear in database migrations and if the creating migration is correct.

Loading history...
25
        $this->api->user_id = auth()->id();
0 ignored issues
show
The method id() does not exist on Illuminate\Contracts\Auth\Factory. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

25
        $this->api->user_id = auth()->/** @scrutinizer ignore-call */ id();

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...
The property user_id does not exist on TaskManager\ApiKeys. Did you mean user?
Loading history...
26
        $this->api->save();
27
        return $this->api->key;
28
    }
29
30
    public function getApi(){
31
        return ApiKeys::where('user_id', auth()->id())->first();
32
    }
33
34
35
    public function exists()
36
    {
37
      // dd($this->api->where('user_id', auth()->id())->first());
0 ignored issues
show
Unused Code Comprehensibility introduced by
70% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
38
        if (count(ApiKeys::where('user_id', auth()->id())->first())) {
39
            return true;
40
        } else {
41
            return false;
42
        }
43
44
    }
45
}