| Conditions | 1 |
| Paths | 1 |
| Total Lines | 51 |
| Code Lines | 36 |
| 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 |
||
| 53 | function let(TaskRepositoryInterface $taskRepository) |
||
| 54 | { |
||
| 55 | $this->newTask = $this->generate_task('Buying salt'); |
||
| 56 | $this->newTask->setStatus(Task::STATUS_REMAINING); |
||
| 57 | |||
| 58 | $this->remainingTask = $this->generate_task('Buying sugar'); |
||
| 59 | $this->remainingTask->setId(1); |
||
| 60 | $this->remainingTask->setStatus(Task::STATUS_REMAINING); |
||
| 61 | |||
| 62 | $this->completedTask = $this->generate_task('Buying milk'); |
||
| 63 | $this->completedTask->setId(2); |
||
| 64 | $this->completedTask->setStatus(Task::STATUS_COMPLETED); |
||
| 65 | |||
| 66 | $this->tasks = [ |
||
| 67 | $this->remainingTask, |
||
| 68 | $this->completedTask |
||
| 69 | ]; |
||
| 70 | |||
| 71 | |||
| 72 | $this->taskRepository = $taskRepository; |
||
| 73 | |||
| 74 | |||
| 75 | |||
| 76 | $this->taskRepository->find($this->remainingTask->getId()) |
||
|
|
|||
| 77 | ->willReturn($this->remainingTask); |
||
| 78 | $this->taskRepository->find($this->completedTask->getId()) |
||
| 79 | ->willReturn($this->completedTask); |
||
| 80 | $this->taskRepository->findByName($this->remainingTask->getName()) |
||
| 81 | ->willReturn($this->remainingTask); |
||
| 82 | $this->taskRepository->findByName($this->completedTask->getName()) |
||
| 83 | ->willReturn($this->completedTask); |
||
| 84 | $this->taskRepository->findByName('Buying salt') |
||
| 85 | ->willThrow(TaskNotFoundException::class); |
||
| 86 | $this->taskRepository->findByName('') |
||
| 87 | ->willThrow(TaskNotFoundException::class); |
||
| 88 | |||
| 89 | $this->taskRepository->remove($this->remainingTask) |
||
| 90 | ->willReturn(null); |
||
| 91 | |||
| 92 | $this->taskRepository->save($this->newTask) |
||
| 93 | ->willReturn(null); |
||
| 94 | |||
| 95 | $this->taskRepository->save($this->remainingTask) |
||
| 96 | ->willReturn(null); |
||
| 97 | $this->taskRepository->save($this->completedTask) |
||
| 98 | ->willReturn(null); |
||
| 99 | $this->taskRepository->removeByStatus(Task::STATUS_COMPLETED) |
||
| 100 | ->willReturn(null); |
||
| 101 | |||
| 102 | $this->beConstructedWith($this->taskRepository); |
||
| 103 | } |
||
| 104 | |||
| 200 |
This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.
This is most likely a typographical error or the method has been renamed.