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

RonasIT / laravel-helpers / 15463936058

05 Jun 2025 09:48AM UTC coverage: 77.839% (+0.2%) from 77.591%
15463936058

Pull #202

github

web-flow
Merge db31ecfb3 into 829e475f7
Pull Request #202: feat: mysql driver for work with enums in migrations

13 of 13 new or added lines in 1 file covered. (100.0%)

25 existing lines in 2 files now uncovered.

1124 of 1444 relevant lines covered (77.84%)

12.57 hits per line

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

0.0
/src/Iterators/DBIterator.php
1
<?php
2

3
namespace RonasIT\Support\Iterators;
4

5
use Iterator;
6
use Generator;
7

8
class DBIterator implements Iterator
9
{
10
    protected $query;
11
    protected $position;
12
    protected $sample = [];
13
    protected $itemsPerPage;
14
    protected $currentItem = [];
15

16
    public function __construct($query, $itemsPerPage = 100)
17
    {
18
        $this->query = $query;
×
19
        $this->itemsPerPage = $itemsPerPage;
×
20
    }
21

22
    public function rewind(): void
23
    {
24
        $this->loadSample();
×
25
    }
26

27
    public function current(): mixed
28
    {
29
        return $this->sample['data'][$this->position];
×
30
    }
31

32
    public function key(): mixed
33
    {
34
        return $this->sample['data'][$this->position]['id'];
×
35
    }
36

37
    public function next(): void
38
    {
39
        $this->position++;
×
40

41
        if ($this->isEndOfSample()) {
×
42
            $this->loadSample($this->sample['current_page'] + 1);
×
43
        }
44
    }
45

46
    public function valid(): bool
47
    {
48
        return !($this->isLastSample() && $this->isEndOfSample());
×
49
    }
50

51
    public function isEndOfSample(): bool
52
    {
53
        return $this->position >= count($this->sample['data']);
×
54
    }
55

56
    public function isLastSample(): bool
57
    {
58
        return $this->sample['current_page'] >= $this->sample['last_page'];
×
59
    }
60

61
    public function loadSample($page = 1): void
62
    {
63
        $this->sample = $this->query
×
64
            ->paginate($this->itemsPerPage, ['*'], 'page', $page)
×
65
            ->toArray();
×
66

67
        $this->position = 0;
×
68
    }
69

70
    public function getGenerator(): Generator
71
    {
72
        $this->rewind();
×
73

74
        while ($this->valid()) {
×
75
            yield $this->current();
×
76

77
            $this->next();
×
78
        }
79
    }
80
}
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

© 2025 Coveralls, Inc