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

NexusPHP / tachycardia / 6604165619

22 Oct 2023 01:35PM UTC coverage: 98.325% (-1.7%) from 100.0%
6604165619

Pull #12

github

paulbalandan
Fix GithubRendererTest
Pull Request #12: feature: Update to PHPUnit 10

411 of 418 new or added lines in 30 files covered. (98.33%)

411 of 418 relevant lines covered (98.33%)

8.32 hits per line

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

95.24
/src/Metadata/LimitCollection.php
1
<?php
2

3
declare(strict_types=1);
4

5
/**
6
 * This file is part of Nexus Tachycardia.
7
 *
8
 * (c) 2021 John Paul E. Balandan, CPA <paulbalandan@gmail.com>
9
 *
10
 * For the full copyright and license information, please view
11
 * the LICENSE file that was distributed with this source code.
12
 */
13

14
namespace Nexus\PHPUnit\Tachycardia\Metadata;
15

16
use Nexus\PHPUnit\Tachycardia\Parameter\Limit as LimitParameter;
17

18
/**
19
 * @internal
20
 *
21
 * @immutable
22
 *
23
 * @implements \IteratorAggregate<int, Limit>
24
 */
25
final class LimitCollection implements \Countable, \IteratorAggregate
26
{
27
    /**
28
     * @var array<int, Limit>
29
     */
30
    private readonly array $limits;
31

32
    private function __construct(Limit ...$limits)
33
    {
34
        $this->limits = array_values($limits);
8✔
35
    }
36

37
    /**
38
     * @param array<int, Limit> $limits
39
     */
40
    public static function fromArray(array $limits): self
41
    {
42
        return new self(...$limits);
8✔
43
    }
44

45
    /**
46
     * @return array<int, Limit>
47
     */
48
    public function asArray(): array
49
    {
50
        return $this->limits;
8✔
51
    }
52

53
    public function count(): int
54
    {
55
        return \count($this->limits);
2✔
56
    }
57

58
    public function isEmpty(): bool
59
    {
60
        return [] === $this->limits;
8✔
61
    }
62

63
    public function getIterator(): LimitCollectionIterator
64
    {
65
        return new LimitCollectionIterator($this);
2✔
66
    }
67

68
    public function mergeWith(self $other): self
69
    {
70
        return new self(...[
8✔
71
            ...$this->asArray(),
8✔
72
            ...$other->asArray(),
8✔
73
        ]);
8✔
74
    }
75

76
    public function reduce(LimitParameter $limitParameter): Limit
77
    {
78
        return array_reduce(
8✔
79
            $this->limits,
8✔
80
            static function (?Limit $initial, Limit $limit): Limit {
8✔
81
                if (null === $initial) {
8✔
82
                    return $limit;
8✔
83
                }
84

85
                if ($limit->isMoreImportantThan($initial)) {
6✔
86
                    return $limit;
6✔
87
                }
88

NEW
89
                return $initial;
×
90
            },
8✔
91
            null,
8✔
92
        ) ?? new TimeLimitForMethod($limitParameter->duration()->asFloat());
8✔
93
    }
94
}
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