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

azjezz / psl / 18747003414

23 Oct 2025 11:33AM UTC coverage: 98.413% (-0.1%) from 98.519%
18747003414

push

github

web-flow
feat: add Graph component with directed and undirected graph support (#547)

Add comprehensive Graph component for with immutable graph data
structures and algorithms for working with directed and undirected graphs.

Features:
- DirectedGraph and UndirectedGraph classes with adjacency list representation
- Pure constructor functions: directed() and undirected()
- Weighted and unweighted edge support
- Graph operations: add_node(), add_edge(), nodes(), neighbors()
- Traversal algorithms: BFS (breadth-first search), DFS (depth-first search)
- Path algorithms: shortest_path(), shortest_path_by(), has_path()
- Topological algorithms: topological_sort(), has_cycle()

Signed-off-by: azjezz <azjezz@protonmail.com>

275 of 286 new or added lines in 17 files covered. (96.15%)

6262 of 6363 relevant lines covered (98.41%)

48.59 hits per line

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

47.06
/src/Psl/Graph/Internal/get_node_key.php
1
<?php
2

3
declare(strict_types=1);
4

5
namespace Psl\Graph\Internal;
6

7
use function get_resource_id;
8
use function is_array;
9
use function is_bool;
10
use function is_float;
11
use function is_int;
12
use function is_object;
13
use function is_resource;
14
use function is_string;
15
use function md5;
16
use function serialize;
17
use function spl_object_id;
18

19
/**
20
 * Generates a unique string key for a node of any type.
21
 *
22
 * @return non-empty-string
23
 *
24
 * @internal
25
 *
26
 * @pure
27
 */
28
function get_node_key(mixed $node): string
29
{
30
    if (is_object($node)) {
93✔
NEW
31
        return 'o:' . spl_object_id($node);
×
32
    }
33

34
    if (is_array($node)) {
93✔
NEW
35
        return 'a:' . md5(serialize($node));
×
36
    }
37

38
    if (is_resource($node)) {
93✔
NEW
39
        return 'r:' . get_resource_id($node);
×
40
    }
41

42
    if (is_bool($node)) {
93✔
NEW
43
        return $node ? 'b:1' : 'b:0';
×
44
    }
45

46
    if (is_int($node)) {
93✔
NEW
47
        return 'i:' . $node;
×
48
    }
49

50
    if (is_float($node)) {
93✔
NEW
51
        return 'f:' . (string) $node;
×
52
    }
53

54
    if (is_string($node)) {
93✔
55
        return 's:' . $node;
93✔
56
    }
57

NEW
58
    if ($node === null) {
×
NEW
59
        return 'n:null';
×
60
    }
61

NEW
62
    return 't:' . md5(serialize($node));
×
63
}
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