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