| Conditions | 1 |
| Paths | 1 |
| Total Lines | 77 |
| Code Lines | 65 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 1 | ||
| 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 |
||
| 25 | public function testReportRoutingSystem(): void |
||
| 26 | { |
||
| 27 | $contents = file_get_contents( |
||
| 28 | __DIR__ . '/../Fixture/report_issue_16853_js.json' |
||
| 29 | ); |
||
| 30 | $report = Report::fromString($contents); |
||
| 31 | |||
| 32 | $tags = $report->getTags(); |
||
| 33 | $contexts = $report->getContexts(); |
||
| 34 | $extras = $report->getExtras(); |
||
| 35 | $reports = $report->getReports(); |
||
| 36 | $user = $report->getUser(); |
||
| 37 | $message = $report->getUserMessage(); |
||
| 38 | $toJson = $report->toJson(); |
||
| 39 | |||
| 40 | $this->assertEquals((object) [ |
||
| 41 | 'server_software' => 'nginx/1.14.2', |
||
| 42 | 'user_agent_string' => 'Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:90.0) Gecko/20100101 Firefox/90.0', |
||
| 43 | 'locale' => 'en', |
||
| 44 | 'configuration_storage' => false, |
||
| 45 | 'php_version' => '7.4.14', |
||
| 46 | 'exception_type' => 'js', |
||
| 47 | ], $tags); |
||
| 48 | $this->assertEquals((object) [ |
||
| 49 | 'os' => (object) ['name' => 'Win'], |
||
| 50 | 'browser' => (object) [ |
||
| 51 | 'name' => 'FIREFOX', |
||
| 52 | 'version' => '90.0', |
||
| 53 | ], |
||
| 54 | ], $contexts); |
||
| 55 | $this->assertEquals((object) [], $extras); |
||
| 56 | $this->assertEquals((object) ['message' => ''], $message); |
||
| 57 | $this->assertEquals((object) ['ip_address' => '0.0.0.0'], $user); |
||
| 58 | $this->assertFalse($report->isMultiReports()); |
||
| 59 | $this->assertFalse($report->hasUserFeedback()); |
||
| 60 | $this->assertEquals([ |
||
| 61 | [ |
||
| 62 | 'sentry.interfaces.Message' => $message, |
||
| 63 | 'release' => '5.2.0-dev', |
||
| 64 | 'dist' => '5.2.0-dev', |
||
| 65 | 'platform' => 'javascript', |
||
| 66 | 'environment' => 'development', |
||
| 67 | 'transaction' => '/database/designer', |
||
| 68 | 'timestamp' => $report->getTimestampUTC(), |
||
| 69 | 'tags' => $tags, |
||
| 70 | 'contexts' => $contexts, |
||
| 71 | 'extra' => $extras, |
||
| 72 | 'user' => $user, |
||
| 73 | 'exception' => [ |
||
| 74 | 'values' => [ |
||
| 75 | (object) [ |
||
| 76 | 'type' => 'TypeError', |
||
| 77 | 'value' => 'can\'t access property "transaction", db is null', |
||
| 78 | 'stacktrace' => (object) [ |
||
| 79 | 'frames' => $reports[0]['exception']['values'][0]->stacktrace->frames, |
||
| 80 | ], |
||
| 81 | ], |
||
| 82 | ], |
||
| 83 | ], |
||
| 84 | 'message' => 'can\'t access property "transaction", db is null', |
||
| 85 | 'culprit' => 'index.php', |
||
| 86 | 'event_id' => $report->getEventId(), |
||
| 87 | ], |
||
| 88 | ], $reports); |
||
| 89 | $this->assertEquals([ |
||
| 90 | 'sentry.interfaces.Message' => $message, |
||
| 91 | 'release' => '5.2.0-dev', |
||
| 92 | 'dist' => '5.2.0-dev', |
||
| 93 | 'platform' => 'javascript', |
||
| 94 | 'environment' => 'development', |
||
| 95 | 'transaction' => '/database/designer', |
||
| 96 | 'timestamp' => $report->getTimestampUTC(), |
||
| 97 | 'tags' => $tags, |
||
| 98 | 'contexts' => $contexts, |
||
| 99 | 'extra' => $extras, |
||
| 100 | 'user' => $user, |
||
| 101 | ], $toJson); |
||
| 102 | } |
||
| 199 |