| Conditions | 2 |
| Paths | 2 |
| Total Lines | 59 |
| Code Lines | 52 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 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 |
||
| 38 | protected function execute(InputInterface $input, OutputInterface $output): int |
||
| 39 | { |
||
| 40 | $this->promise |
||
| 41 | ->getDatabaseProvider() |
||
| 42 | ->database() |
||
| 43 | ->delete('post') |
||
| 44 | ->run(); |
||
| 45 | |||
| 46 | $this->promise |
||
| 47 | ->getDatabaseProvider() |
||
| 48 | ->database() |
||
| 49 | ->delete('post_tag') |
||
| 50 | ->run(); |
||
| 51 | |||
| 52 | $this->promise |
||
| 53 | ->getDatabaseProvider() |
||
| 54 | ->database() |
||
| 55 | ->delete('tag') |
||
| 56 | ->run(); |
||
| 57 | |||
| 58 | $this->promise |
||
| 59 | ->getDatabaseProvider() |
||
| 60 | ->database() |
||
| 61 | ->delete('user') |
||
| 62 | ->run(); |
||
| 63 | |||
| 64 | $this->promise |
||
| 65 | ->getDatabaseProvider() |
||
| 66 | ->database() |
||
| 67 | ->delete('comment') |
||
| 68 | ->run(); |
||
| 69 | |||
| 70 | return 0 === $this->promise |
||
| 71 | ->getORM() |
||
| 72 | ->getRepository(Post::class) |
||
| 73 | ->select() |
||
| 74 | ->count() + |
||
| 75 | $this->promise |
||
| 76 | ->getORM() |
||
| 77 | ->getRepository(PostTag::class) |
||
| 78 | ->select() |
||
| 79 | ->count() + |
||
| 80 | $this->promise |
||
| 81 | ->getORM() |
||
| 82 | ->getRepository(Tag::class) |
||
| 83 | ->select() |
||
| 84 | ->count() + |
||
| 85 | $this->promise |
||
| 86 | ->getORM() |
||
| 87 | ->getRepository(User::class) |
||
| 88 | ->select() |
||
| 89 | ->count() + |
||
| 90 | $this->promise |
||
| 91 | ->getORM() |
||
| 92 | ->getRepository(Comment::class) |
||
| 93 | ->select() |
||
| 94 | ->count() |
||
| 95 | ? ExitCode::OK |
||
| 96 | : ExitCode::UNSPECIFIED_ERROR; |
||
| 97 | } |
||
| 99 |