| Conditions | 1 |
| Paths | 1 |
| Total Lines | 60 |
| Code Lines | 39 |
| 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 |
||
| 45 | private function createGitlabClientFacade(): JiraClientFacade |
||
| 46 | { |
||
| 47 | $issueServiceMock = $this->getMockBuilder(IssueService::class)->disableOriginalConstructor() |
||
| 48 | ->onlyMethods(['search', 'getComments']) |
||
| 49 | ->getMock() |
||
| 50 | ; |
||
| 51 | |||
| 52 | $issueSearchResult = new IssueSearchResult(); |
||
| 53 | |||
| 54 | $testIssue = new Issue(); |
||
| 55 | $testIssue->key = 'test-key'; |
||
| 56 | $issueSearchResult->setIssues([$testIssue]); |
||
| 57 | static::returnValue($issueSearchResult); |
||
| 58 | |||
| 59 | $issueServiceMock |
||
| 60 | ->method('search') |
||
| 61 | ->willReturn( |
||
| 62 | $issueSearchResult |
||
| 63 | ) |
||
| 64 | ; |
||
| 65 | |||
| 66 | $testComment = new Comment(); |
||
| 67 | $testComment->body = self::TICKET_COMMENT_BODY; |
||
| 68 | $testComment->updated = self::TICKET_COMMENT_UPDATED; |
||
|
|
|||
| 69 | |||
| 70 | $testComments = new \stdClass(); |
||
| 71 | $testComments->comments = [$testComment]; |
||
| 72 | $testAuthor = new Author(); |
||
| 73 | $testAuthor->emailAddress = self::TESTUSER_EXAMPLE_COM; |
||
| 74 | $testComment->author = $testAuthor; |
||
| 75 | $issueServiceMock |
||
| 76 | ->method('getComments') |
||
| 77 | ->willReturn( |
||
| 78 | $testComments |
||
| 79 | ) |
||
| 80 | ; |
||
| 81 | |||
| 82 | $jiraClientFactoryMock = $this->getMockBuilder(JiraClientFactory::class) |
||
| 83 | ->onlyMethods(['createJiraClient', 'createJiraConfigDto']) |
||
| 84 | ->getMock() |
||
| 85 | ; |
||
| 86 | $jiraClientFactoryMock |
||
| 87 | ->method('createJiraClient') |
||
| 88 | ->willReturn($issueServiceMock) |
||
| 89 | ; |
||
| 90 | |||
| 91 | $jiraClientFactoryMock->method('createJiraConfigDto') |
||
| 92 | ->willReturn(new JiraConfigDto('', '', self::TESTUSER_EXAMPLE_COM, 0, '')) |
||
| 93 | ; |
||
| 94 | |||
| 95 | $jiraClientFacadeMock = $this->getMockBuilder(JiraClientFacade::class) |
||
| 96 | ->onlyMethods(['getFactory']) |
||
| 97 | ->getMock() |
||
| 98 | ; |
||
| 99 | $jiraClientFacadeMock |
||
| 100 | ->method('getFactory') |
||
| 101 | ->willReturn($jiraClientFactoryMock) |
||
| 102 | ; |
||
| 103 | |||
| 104 | return $jiraClientFacadeMock; |
||
| 105 | } |
||
| 107 |
Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.
Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..