Conditions | 11 |
Paths | 84 |
Total Lines | 60 |
Code Lines | 42 |
Lines | 0 |
Ratio | 0 % |
Changes | 0 |
Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.
For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.
Commonly applied refactorings include:
If many parameters/temporary variables are present:
1 | <?php |
||
19 | public static function activity($description = null) |
||
20 | { |
||
21 | $userType = trans('LaravelLogger::laravel-logger.userTypes.guest'); |
||
22 | $userId = null; |
||
23 | |||
24 | if (\Auth::check()) { |
||
25 | $userType = trans('LaravelLogger::laravel-logger.userTypes.registered'); |
||
26 | $userId = \Request::user()->id; |
||
27 | } |
||
28 | |||
29 | if (Crawler::isCrawler()) { |
||
30 | $userType = trans('LaravelLogger::laravel-logger.userTypes.crawler'); |
||
31 | $description = $userType.' '.trans('LaravelLogger::laravel-logger.verbTypes.crawled').' '.\Request::fullUrl(); |
||
32 | } |
||
33 | |||
34 | if (!$description) { |
||
35 | switch (strtolower(\Request::method())) { |
||
36 | case 'post': |
||
37 | $verb = trans('LaravelLogger::laravel-logger.verbTypes.created'); |
||
38 | break; |
||
39 | |||
40 | case 'patch': |
||
41 | case 'put': |
||
42 | $verb = trans('LaravelLogger::laravel-logger.verbTypes.edited'); |
||
43 | break; |
||
44 | |||
45 | case 'delete': |
||
46 | $verb = trans('LaravelLogger::laravel-logger.verbTypes.deleted'); |
||
47 | break; |
||
48 | |||
49 | case 'get': |
||
50 | default: |
||
51 | $verb = trans('LaravelLogger::laravel-logger.verbTypes.viewed'); |
||
52 | break; |
||
53 | } |
||
54 | |||
55 | $description = $verb.' '.\Request::path(); |
||
56 | } |
||
57 | |||
58 | $data = [ |
||
59 | 'description' => $description, |
||
60 | 'userType' => $userType, |
||
61 | 'userId' => $userId, |
||
62 | 'route' => \Request::fullUrl(), |
||
63 | 'ipAddress' => \Request::ip(), |
||
64 | 'userAgent' => \Request::header('user-agent'), |
||
65 | 'locale' => \Request::header('accept-language'), |
||
66 | 'referer' => \Request::header('referer'), |
||
67 | 'methodType' => \Request::method(), |
||
68 | ]; |
||
69 | |||
70 | // Validation Instance |
||
71 | $validator = Validator::make($data, Activity::Rules([])); |
||
72 | if ($validator->fails()) { |
||
73 | $errors = self::prepareErrorMessage($validator->errors(), $data); |
||
74 | if (config('LaravelLogger.logDBActivityLogFailuresToFile')) { |
||
75 | Log::error('Failed to record activity event. Failed Validation: '.$errors); |
||
76 | } |
||
77 | } else { |
||
78 | self::storeActivity($data); |
||
79 | } |
||
122 |
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