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

sanmai / pipeline / 21476528949

29 Jan 2026 11:33AM UTC coverage: 98.911%. First build
21476528949

Pull #292

github

web-flow
Merge 094312eac into d495c42b3
Pull Request #292: Add Buffer helper

6 of 12 new or added lines in 2 files covered. (50.0%)

545 of 551 relevant lines covered (98.91%)

119.57 hits per line

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

0.0
/src/Helper/WindowBuffer.php
1
<?php
2

3
/**
4
 * Copyright 2017, 2018 Alexey Kopytko <alexey@kopytko.com>
5
 *
6
 * Licensed under the Apache License, Version 2.0 (the "License");
7
 * you may not use this file except in compliance with the License.
8
 * You may obtain a copy of the License at
9
 *
10
 * http://www.apache.org/licenses/LICENSE-2.0
11
 *
12
 * Unless required by applicable law or agreed to in writing, software
13
 * distributed under the License is distributed on an "AS IS" BASIS,
14
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
 * See the License for the specific language governing permissions and
16
 * limitations under the License.
17
 */
18

19
declare(strict_types=1);
20

21
namespace Pipeline\Helper;
22

23
use function count;
24

25
use Countable;
26
use Iterator;
27
use Override;
28

29
/**
30
 * @template TKey
31
 * @template TValue
32
 *
33
 * @internal
34
 */
35
class WindowBuffer implements Countable
36
{
37
    /** @var array<int, array{TKey, TValue}> */
38
    private array $buffer = [];
39

40
    private int $headKey = 0;
41

42
    /** @return TKey */
43
    public function keyAt(int $position): mixed
44
    {
NEW
45
        return $this->buffer[$this->headKey + $position][0];
×
46
    }
47

48
    /** @return TValue */
49
    public function valueAt(int $position): mixed
50
    {
NEW
51
        return $this->buffer[$this->headKey + $position][1];
×
52
    }
53

54
    /** @param Iterator<TKey, TValue> $iterator */
55
    public function append(Iterator $iterator): void
56
    {
NEW
57
        $this->buffer[] = [$iterator->key(), $iterator->current()];
×
58
    }
59

60
    #[Override]
61
    public function count(): int
62
    {
NEW
63
        return count($this->buffer);
×
64
    }
65

66
    public function dropOldest(): void
67
    {
NEW
68
        unset($this->buffer[$this->headKey]);
×
NEW
69
        ++$this->headKey;
×
70
    }
71
}
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