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

sanmai / pipeline / 21277624834

23 Jan 2026 07:01AM UTC coverage: 98.564%. First build
21277624834

Pull #292

github

web-flow
Merge ade062d8d into 33a0e9885
Pull Request #292: Add Buffer helper

6 of 14 new or added lines in 2 files covered. (42.86%)

549 of 557 relevant lines covered (98.56%)

117.9 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
/**
26
 * @template TKey
27
 * @template TValue
28
 *
29
 * @internal
30
 */
31
final class WindowBuffer
32
{
33
    /** @var array<int, array{TKey, TValue}> */
34
    private array $buffer = [];
35

36
    private int $headKey = 0;
37

38
    public function keyAt(int $position): mixed
39
    {
NEW
40
        return $this->buffer[$this->headKey + $position][0];
×
41
    }
42

43
    public function valueAt(int $position): mixed
44
    {
NEW
45
        return $this->buffer[$this->headKey + $position][1];
×
46
    }
47

48
    public function append(mixed $key, mixed $value): void
49
    {
NEW
50
        $this->buffer[] = [$key, $value];
×
51
    }
52

53
    public function count(): int
54
    {
NEW
55
        return count($this->buffer);
×
56
    }
57

58
    public function trimToMax(int $maxSize, int &$position): void
59
    {
NEW
60
        while ($this->count() > $maxSize) {
×
NEW
61
            unset($this->buffer[$this->headKey]);
×
NEW
62
            ++$this->headKey;
×
NEW
63
            --$position;
×
64
        }
65
    }
66
}
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