1 | <?php |
||
2 | |||
3 | namespace App\Main\Plugin; |
||
4 | |||
5 | use SavinMikhail\CommentsDensity\AnalyzeComments\Analyzer\DTO\Output\CommentDTO; |
||
6 | use SavinMikhail\CommentsDensity\AnalyzeComments\Analyzer\DTO\Output\Report; |
||
7 | use SavinMikhail\CommentsDensity\AnalyzeComments\Comments\RegularComment; |
||
8 | use SavinMikhail\CommentsDensity\AnalyzeComments\Config\DTO\Config; |
||
9 | use SavinMikhail\CommentsDensity\AnalyzeComments\File\FileEditor; |
||
10 | use SavinMikhail\CommentsDensity\Plugin\PluginInterface; |
||
11 | |||
12 | final readonly class RemoveRelaxComment implements PluginInterface |
||
0 ignored issues
–
show
Bug
introduced
by
![]() |
|||
13 | { |
||
14 | public function handle(Report $report, Config $config): void |
||
15 | { |
||
16 | foreach ($report->comments as $comment) { |
||
17 | if ($comment->commentType !== RegularComment::NAME) { |
||
18 | continue; |
||
19 | } |
||
20 | |||
21 | if (!str_contains($comment->content, '// relax')) { |
||
22 | continue; |
||
23 | } |
||
24 | |||
25 | $newComment = new CommentDTO( |
||
26 | commentType: $comment->commentType, |
||
27 | commentTypeColor: $comment->commentTypeColor, |
||
28 | file: $comment->file, |
||
29 | line: $comment->line, |
||
30 | content: '', |
||
31 | ); |
||
32 | (new FileEditor())->updateCommentInFile($newComment); |
||
33 | } |
||
34 | } |
||
35 | } |
||
36 |