Total Complexity | 7 |
Total Lines | 60 |
Duplicated Lines | 0 % |
Changes | 4 | ||
Bugs | 1 | Features | 0 |
1 | <?php |
||
10 | trait IsAnalytic |
||
11 | { |
||
12 | public function initializeIsAnalytic() |
||
13 | { |
||
14 | $this->connection = config('apanalytics.db_connection'); |
||
15 | $this->collection = Str::plural(Str::before($this->getTable(), '_analytic')); |
||
16 | $this->dates = ['created_at', 'updated_at']; |
||
17 | $this->guarded = []; |
||
18 | } |
||
19 | |||
20 | public function canViewCollection(User $user = null) |
||
21 | { |
||
22 | if (app()->runningInConsole()) { |
||
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); |
||
43 | $period = CarbonPeriod::create($startDate, "1 month", $endDate); |
||
44 | |||
45 | $output = []; |
||
46 | foreach ($period as $date) { |
||
47 | $date = $date->format('d-m-Y'); |
||
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) |
||
70 | } |
||
71 | } |
||
72 |
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:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths