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

azjezz / psl / 22680186990

04 Mar 2026 05:04PM UTC coverage: 97.34% (-1.0%) from 98.375%
22680186990

Pull #610

github

azjezz
perf: replace PSL calls with native PHP builtins and fix O(n2) algorithms

Signed-off-by: azjezz <azjezz@protonmail.com>
Pull Request #610: perf: replace PSL calls with native PHP builtins and fix O(n2) algorithms

319 of 355 new or added lines in 90 files covered. (89.86%)

64 existing lines in 12 files now uncovered.

9258 of 9511 relevant lines covered (97.34%)

34.97 hits per line

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

83.33
/src/Psl/Dict/flip.php
1
<?php
2

3
declare(strict_types=1);
4

5
namespace Psl\Dict;
6

7
use function array_flip;
8
use function is_array;
9

10
/**
11
 * Flips the keys and values of an iterable.
12
 *
13
 * In case of duplicate values, later keys will overwrite the previous ones.
14
 *
15
 * Examples:
16
 *
17
 *      Dict\flip(['a' => 1, 'b' => 2, 'c' => 3])
18
 *      => Dict(1 => 'a', 2 => 'b', 3 => 'c')
19
 *
20
 * @template Tk of array-key
21
 * @template Tv of array-key
22
 *
23
 * @param iterable<Tk, Tv> $iterable
24
 *
25
 * @return array<Tv, Tk>
26
 */
27
function flip(iterable $iterable): array
28
{
29
    if (is_array($iterable)) {
1✔
NEW
30
        return array_flip($iterable);
×
31
    }
32

33
    $result = [];
1✔
34
    foreach ($iterable as $key => $value) {
1✔
35
        $result[$value] = $key;
1✔
36
    }
37

38
    return $result;
1✔
39
}
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