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.

Issues (20)

src/Traits/IsAnalytic.php (10 issues)

1
<?php
2
3
namespace AshPowell\APAnalytics\Traits;
4
5
use App\User;
0 ignored issues
show
The type App\User was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
6
use Illuminate\Support\Str;
7
use \Carbon\Carbon;
8
use \Carbon\CarbonPeriod;
9
10
trait IsAnalytic
11
{
12
    public function initializeIsAnalytic()
13
    {
14
        $this->connection = config('apanalytics.db_connection');
0 ignored issues
show
Bug Best Practice introduced by
The property connection does not exist. Although not strictly required by PHP, it is generally a best practice to declare properties explicitly.
Loading history...
15
        $this->collection = Str::plural(Str::before($this->getTable(), '_analytic'));
0 ignored issues
show
It seems like getTable() must be provided by classes using this trait. How about adding it as abstract method to this trait? ( Ignorable by Annotation )

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

15
        $this->collection = Str::plural(Str::before($this->/** @scrutinizer ignore-call */ getTable(), '_analytic'));
Loading history...
Bug Best Practice introduced by
The property collection does not exist. Although not strictly required by PHP, it is generally a best practice to declare properties explicitly.
Loading history...
16
        $this->dates      = ['created_at', 'updated_at'];
0 ignored issues
show
Bug Best Practice introduced by
The property dates does not exist. Although not strictly required by PHP, it is generally a best practice to declare properties explicitly.
Loading history...
17
        $this->guarded    = [];
0 ignored issues
show
Bug Best Practice introduced by
The property guarded does not exist. Although not strictly required by PHP, it is generally a best practice to declare properties explicitly.
Loading history...
18
    }
19
20
    public function canViewCollection(User $user = null)
21
    {
22
        if (app()->runningInConsole()) {
0 ignored issues
show
The method runningInConsole() does not exist on Illuminate\Container\Container. Are you sure you never get this type here, but always one of the subclasses? ( Ignorable by Annotation )

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

22
        if (app()->/** @scrutinizer ignore-call */ runningInConsole()) {
Loading history...
23
            return true;
24
        }
25
26
        if (! $user) {
27
            return false;
28
        }
29
30
        return $user->isAnyAdmin();
31
    }
32
33
    /**
34
     * Returns the month on month analytic count
35
     *
36
     * @param string $period
37
     * @return Array
38
     */
39
    public static function getCumulativeGrowthData($period = 6)
40
    {
41
        $endDate   = now();
42
        $startDate = $endDate->copy()->subMonths($period);
0 ignored issues
show
It seems like $period can also be of type string; however, parameter $value of Carbon\Carbon::subMonths() does only seem to accept integer, maybe add an additional type check? ( Ignorable by Annotation )

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

42
        $startDate = $endDate->copy()->subMonths(/** @scrutinizer ignore-type */ $period);
Loading history...
43
        $period    = CarbonPeriod::create($startDate, "1 month", $endDate);
44
45
        $output = [];
46
        foreach ($period as $date) {
47
            $date  = $date->format('d-m-Y');
0 ignored issues
show
The method format() does not exist on null. ( Ignorable by Annotation )

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

47
            /** @scrutinizer ignore-call */ 
48
            $date  = $date->format('d-m-Y');

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...
48
            $output[$date] = (new static)->getCountForDate($date, 'd-m-Y');
49
        }
50
51
        return $output;
52
    }
53
54
    /**
55
     * Returns the analytic count for the specified month
56
     *
57
     * @param String $date
58
     * @param String $format
59
     * @return Int
60
     */
61
    public static function getCountForDate($date, $format)
62
    {
63
        $currentDate = Carbon::createFromFormat($format, $date);
64
65
        $currentCount = (new static)
66
            ->where('created_at', '<=', $currentDate)
0 ignored issues
show
It seems like where() must be provided by classes using this trait. How about adding it as abstract method to this trait? ( Ignorable by Annotation )

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

66
            ->/** @scrutinizer ignore-call */ where('created_at', '<=', $currentDate)
Loading history...
67
            ->count();
68
69
        return $currentCount;
70
    }
71
}
72