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

systemsdk / phpcpd / #6

23 Mar 2025 04:51PM UTC coverage: 75.711% (-0.08%) from 75.789%
#6

push

DKravtsov
phpcpd 8.1.0 release. Added Suffix Tree-based algorithm for code clone detection (experimental), added progress bar. Made codebase refactoring. Updated packages: sebastian/cli-parser, sebastian/version, phpunit/php-file-iterator, phpunit/php-timer. Updated tests to the PHPUnit 12.

101 of 126 new or added lines in 10 files covered. (80.16%)

1 existing line in 1 file now uncovered.

692 of 914 relevant lines covered (75.71%)

3.7 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) {
×
NEW
33
                $endLine = $file->endLine();
×
34
                printf(
×
35
                    '  %s%s:%d-%d%s' . PHP_EOL,
×
36
                    $firstOccurrence ? '- ' : '  ',
×
37
                    $file->name(),
×
38
                    $file->startLine(),
×
NEW
39
                    $endLine ? $endLine + 1 : ($file->startLine() + $clone->numberOfLines()),
×
40
                    $firstOccurrence ? ' (' . $clone->numberOfLines() . ' lines)' : ''
×
41
                );
×
42

43
                $firstOccurrence = false;
×
44
            }
45

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

50
            print PHP_EOL;
×
51
        }
52

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

56
            return;
×
57
        }
58

59
        printf(
×
60
            '%s duplicated lines out of %d total lines of code.' . PHP_EOL .
×
61
            'Average code clone size is %d lines, the largest code clone has %d lines' . PHP_EOL . PHP_EOL,
×
62
            $clones->percentage(),
×
63
            $clones->numberOfLines(),
×
64
            $clones->averageSize(),
×
65
            $clones->largestSize()
×
66
        );
×
67
    }
68
}
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