Conditions | 5 |
Paths | 4 |
Total Lines | 52 |
Code Lines | 30 |
Lines | 0 |
Ratio | 0 % |
Changes | 2 | ||
Bugs | 0 | Features | 1 |
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 |
||
35 | public static function simulate($matchId, $completeResult = true) |
||
36 | { |
||
37 | $result = MatchResult::complete() |
||
38 | ->where( |
||
39 | [ |
||
40 | 'id' => $matchId |
||
41 | ] |
||
42 | )->first(); |
||
43 | if (!empty($result) && !$result->simulated) { |
||
44 | //simulate match |
||
45 | $match = \App\Lib\DsManager\Models\Match::fromArray( |
||
46 | \App\Lib\DsManager\Models\Orm\Match::complete() |
||
|
|||
47 | ->where( |
||
48 | [ |
||
49 | 'id' => $matchId |
||
50 | ] |
||
51 | )->first()->toArray() |
||
52 | ); |
||
53 | |||
54 | $matchResult = $match->simulate()->toArray(); |
||
55 | |||
56 | $result = MatchResult::where( |
||
57 | [ |
||
58 | 'id' => $matchId |
||
59 | ] |
||
60 | )->update( |
||
61 | MatchResult::resolveAttributes( |
||
62 | $matchResult, |
||
63 | $matchId |
||
64 | ) |
||
65 | ); |
||
66 | if ($result === 1) { |
||
67 | if ($completeResult) { |
||
68 | $result = MatchResult::complete() |
||
69 | ->where( |
||
70 | [ |
||
71 | 'id' => $matchId |
||
72 | ] |
||
73 | )->first(); |
||
74 | } else { |
||
75 | $result = MatchResult::teams() |
||
76 | ->where( |
||
77 | [ |
||
78 | 'id' => $matchId |
||
79 | ] |
||
80 | )->first(); |
||
81 | } |
||
82 | } |
||
83 | |||
84 | } |
||
85 | return $result; |
||
86 | } |
||
87 | } |
This check marks calls to methods that do not seem to exist on an object.
This is most likely the result of a method being renamed without all references to it being renamed likewise.