| Conditions | 3 |
| Paths | 3 |
| Total Lines | 80 |
| Code Lines | 67 |
| 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 |
||
| 21 | public function testFields() |
||
| 22 | { |
||
| 23 | $values = [ |
||
| 24 | 'id' => '539fd88c101897f7cd000007', |
||
| 25 | 'object' => 'motor_vehicle_report', |
||
| 26 | 'uri' => '/v1/motor_vehicle_reports/539fd88c101897f7cd000007', |
||
| 27 | 'status' => 'consider', |
||
| 28 | 'created_at' => '2014-01-18T12:34:00Z', |
||
| 29 | 'completed_at' => '2014-01-18T12:35:30Z', |
||
| 30 | 'turnaround_time' => 90, |
||
| 31 | 'full_name' => 'John Alfred Smith', |
||
| 32 | 'license_number' => 'F2111132', |
||
| 33 | 'license_state' => 'CA', |
||
| 34 | 'license_status' => 'valid', |
||
| 35 | 'license_type' => 'non-commercial', |
||
| 36 | 'license_class' => 'C', |
||
| 37 | 'expiration_date' => '2016-07-24', |
||
| 38 | 'issued_date' => '2006-12-03', |
||
| 39 | 'first_issued_date' => '2000-01-14', |
||
| 40 | 'inferred_issued_date' => NULL, |
||
| 41 | 'restrictions' => [], |
||
| 42 | 'accidents' => [ |
||
| 43 | [ |
||
| 44 | 'accident_date' => '2009-04-12', |
||
| 45 | 'description' => 'property damage', |
||
| 46 | 'city' => NULL, |
||
| 47 | 'county' => 'SAN FRANCISCO', |
||
| 48 | 'state' => NULL, |
||
| 49 | 'order_number' => '33-435932', |
||
| 50 | 'points' => NULL, |
||
| 51 | 'vehicle_speed' => NULL, |
||
| 52 | 'reinstatement_date' => NULL, |
||
| 53 | 'action_taken' => 'police report filed', |
||
| 54 | 'ticket_number' => NULL, |
||
| 55 | 'enforcing_agency' => 'San Francisco PD', |
||
| 56 | 'jurisdiction' => NULL, |
||
| 57 | 'severity' => NULL, |
||
| 58 | 'violation_number' => NULL, |
||
| 59 | 'license_plate' => '6UM6938', |
||
| 60 | 'fine_amount' => NULL, |
||
| 61 | 'state_code' => NULL, |
||
| 62 | 'acd_code' => NULL, |
||
| 63 | 'injury_accident' => false, |
||
| 64 | 'fatality_accident' => false, |
||
| 65 | 'fatality_count' => 0, |
||
| 66 | 'injury_count' => 0, |
||
| 67 | 'vehicles_involved_count' => 1, |
||
| 68 | 'report_number' => NULL, |
||
| 69 | 'policy_number' => NULL, |
||
| 70 | ] |
||
| 71 | ], |
||
| 72 | 'violations' => [ |
||
| 73 | [ |
||
| 74 | 'type' => 'conviction', |
||
| 75 | 'issued_date' => '2011-11-14', |
||
| 76 | 'conviction_date' => '2010-04-11', |
||
| 77 | 'description' => 'speeding 15-19 mph', |
||
| 78 | 'points' => 0, |
||
| 79 | 'city' => NULL, |
||
| 80 | 'county' => 'SANTA CLARA', |
||
| 81 | 'state' => 'California', |
||
| 82 | 'ticket_number' => '2D55555', |
||
| 83 | 'disposition' => NULL, |
||
| 84 | 'category' => NULL, |
||
| 85 | 'court_name' => NULL, |
||
| 86 | 'acd_code' => NULL, |
||
| 87 | 'state_code' => NULL, |
||
| 88 | 'docket' => NULL, |
||
| 89 | ] |
||
| 90 | ] |
||
| 91 | ]; |
||
| 92 | |||
| 93 | $motorVehicleReport = $this->getMotorVehicleReport($values); |
||
| 94 | |||
| 95 | foreach ($values as $key => $value) { |
||
| 96 | if (is_array($value)) { |
||
| 97 | $value = collect($value); |
||
| 98 | } |
||
| 99 | |||
| 100 | $this->assertEquals($value, $motorVehicleReport->{$key}); |
||
| 101 | } |
||
| 109 | } |