| Conditions | 1 |
| Paths | 1 |
| Total Lines | 60 |
| Code Lines | 39 |
| 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 |
||
| 57 | private function createGitlabClientFacade(): JiraClientFacade |
||
| 58 | { |
||
| 59 | $issueServiceMock = $this->getMockBuilder(IssueService::class)->disableOriginalConstructor() |
||
| 60 | ->onlyMethods(['search','getComments']) |
||
| 61 | ->getMock() |
||
| 62 | ; |
||
| 63 | |||
| 64 | $issueSearchResult = new IssueSearchResult(); |
||
| 65 | |||
| 66 | $testIssue = new Issue(); |
||
| 67 | $testIssue->key = 'test-key'; |
||
| 68 | $issueSearchResult->setIssues([$testIssue]); |
||
| 69 | $this->returnValue($issueSearchResult); |
||
| 70 | |||
| 71 | $issueServiceMock |
||
| 72 | ->method('search') |
||
| 73 | ->willReturn( |
||
| 74 | $issueSearchResult |
||
| 75 | ) |
||
| 76 | ; |
||
| 77 | |||
| 78 | $testComment = new Comment(); |
||
| 79 | $testComment->body= self::TICKET_COMMENT_BODY; |
||
| 80 | $testComment->updated= self::TICKET_COMMENT_UPDATED; |
||
|
|
|||
| 81 | |||
| 82 | $testComments = new \stdClass(); |
||
| 83 | $testComments->comments = [$testComment]; |
||
| 84 | $testAuthor = new Author(); |
||
| 85 | $testAuthor->emailAddress = self::TESTUSER_EXAMPLE_COM; |
||
| 86 | $testComment->author = $testAuthor; |
||
| 87 | $issueServiceMock |
||
| 88 | ->method('getComments') |
||
| 89 | ->willReturn( |
||
| 90 | $testComments |
||
| 91 | ) |
||
| 92 | ; |
||
| 93 | |||
| 94 | $jiraClientFactoryMock = $this->getMockBuilder(JiraClientFactory::class) |
||
| 95 | ->onlyMethods(['createJiraClient', 'createJiraConfigDto']) |
||
| 96 | ->getMock() |
||
| 97 | ; |
||
| 98 | $jiraClientFactoryMock |
||
| 99 | ->method('createJiraClient') |
||
| 100 | ->willReturn($issueServiceMock) |
||
| 101 | ; |
||
| 102 | |||
| 103 | $jiraClientFactoryMock->method('createJiraConfigDto') |
||
| 104 | ->willReturn(new JiraConfigDto('', '', self::TESTUSER_EXAMPLE_COM,0,'')) |
||
| 105 | ; |
||
| 106 | |||
| 107 | $jiraClientFacadeMock = $this->getMockBuilder(JiraClientFacade::class) |
||
| 108 | ->onlyMethods(['getFactory']) |
||
| 109 | ->getMock() |
||
| 110 | ; |
||
| 111 | $jiraClientFacadeMock |
||
| 112 | ->method('getFactory') |
||
| 113 | ->willReturn($jiraClientFactoryMock) |
||
| 114 | ; |
||
| 115 | |||
| 116 | return $jiraClientFacadeMock; |
||
| 117 | } |
||
| 119 |
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..