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

systemsdk / phpcpd / #12

13 Apr 2025 04:42PM UTC coverage: 75.711%. Remained the same
#12

push

DKravtsov
phpcpd 8.1.1 release. Available installation via composer.

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

84.62
/src/CodeCloneMapIterator.php
1
<?php
2

3
declare(strict_types=1);
4

5
namespace Systemsdk\PhpCPD;
6

7
use Iterator;
8

9
use function array_reverse;
10
use function count;
11
use function usort;
12

13
final class CodeCloneMapIterator implements Iterator
14
{
15
    /**
16
     * @var array<int, CodeClone>
17
     */
18
    private array $clones;
19

20
    private int $position = 0;
21

22
    public function __construct(CodeCloneMap $clones)
23
    {
24
        $this->clones = $clones->clones();
1✔
25

26
        usort(
1✔
27
            $this->clones,
1✔
28
            static function (CodeClone $a, CodeClone $b): int {
1✔
29
                return $a->numberOfLines() <=> $b->numberOfLines();
×
30
            }
1✔
31
        );
1✔
32

33
        $this->clones = array_reverse($this->clones);
1✔
34
    }
35

36
    public function rewind(): void
37
    {
38
        $this->position = 0;
1✔
39
    }
40

41
    public function valid(): bool
42
    {
43
        return $this->position < count($this->clones);
1✔
44
    }
45

46
    public function key(): int
47
    {
48
        return $this->position;
×
49
    }
50

51
    public function current(): CodeClone
52
    {
53
        return $this->clones[$this->position];
1✔
54
    }
55

56
    public function next(): void
57
    {
58
        $this->position++;
1✔
59
    }
60
}
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