• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

systemsdk / phpcpd / #18

30 Apr 2025 10:36PM UTC coverage: 76.578% (+0.9%) from 75.711%
#18

push

DKravtsov
phpcpd 8.2.0 release. Added possibility to generate html report, extended report xml file, fixed some bugs, updated documentation.

36 of 37 new or added lines in 4 files covered. (97.3%)

716 of 935 relevant lines covered (76.58%)

3.65 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

0.0
/src/Log/Text.php
1
<?php
2

3
declare(strict_types=1);
4

5
namespace Systemsdk\PhpCPD\Log;
6

7
use Systemsdk\PhpCPD\CodeCloneMap;
8

9
use function count;
10
use function printf;
11

12
use const PHP_EOL;
13

14
final class Text
15
{
16
    public function printResult(CodeCloneMap $clones, bool $verbose): void
17
    {
18
        $countClones = count($clones);
×
19

20
        if ($countClones > 0) {
×
21
            printf(
×
22
                'Found %d code clones with %d duplicated lines in %d files:' . PHP_EOL . PHP_EOL,
×
23
                $countClones,
×
24
                $clones->numberOfDuplicatedLines(),
×
25
                $clones->numberOfFilesWithClones()
×
26
            );
×
27
        }
28

29
        foreach ($clones as $clone) {
×
30
            $firstOccurrence = true;
×
31

32
            foreach ($clone->files() as $file) {
×
33
                printf(
×
34
                    '  %s%s:%d-%d%s' . PHP_EOL,
×
35
                    $firstOccurrence ? '- ' : '  ',
×
36
                    $file->name(),
×
37
                    $file->startLine(),
×
NEW
38
                    $file->endLine(),
×
39
                    $firstOccurrence ? ' (' . $clone->numberOfLines() . ' lines)' : ''
×
40
                );
×
41

42
                $firstOccurrence = false;
×
43
            }
44

45
            if ($verbose) {
×
46
                print PHP_EOL . $clone->lines('    ');
×
47
            }
48

49
            print PHP_EOL;
×
50
        }
51

52
        if ($clones->isEmpty()) {
×
53
            print 'No code clones found.' . PHP_EOL . PHP_EOL;
×
54

55
            return;
×
56
        }
57

58
        printf(
×
59
            '%s duplicated lines out of %d total lines of code.' . PHP_EOL .
×
60
            'Average code clone size is %d lines, the largest code clone has %d lines' . PHP_EOL . PHP_EOL,
×
61
            $clones->percentage(),
×
62
            $clones->numberOfLines(),
×
63
            $clones->averageSize(),
×
64
            $clones->largestSize()
×
65
        );
×
66
    }
67
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc