Passed
Push — claude/understand-crawl-pLOr9 ( efe806 )
by Akihito
02:23
created

Results::toArray()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 1
c 1
b 0
f 0
nc 1
nop 0
dl 0
loc 3
rs 10
1
<?php
2
3
declare(strict_types=1);
4
5
namespace BEAR\Resource\Batch;
6
7
use function array_key_exists;
8
9
/**
10
 * Batch processing results mapped by URI
11
 */
12
final class Results
13
{
14
    /**
15
     * @param array<string, mixed> $results URI => result mapping
16
     */
17
    public function __construct(
18
        private readonly array $results,
19
    ) {
20
    }
21
22
    /**
23
     * Get result for a specific URI
24
     */
25
    public function get(string $uri): mixed
26
    {
27
        return $this->results[$uri] ?? null;
28
    }
29
30
    /**
31
     * Check if result exists for a URI
32
     */
33
    public function has(string $uri): bool
34
    {
35
        return array_key_exists($uri, $this->results);
36
    }
37
38
    /**
39
     * Get all results as array
40
     *
41
     * @return array<string, mixed>
42
     */
43
    public function toArray(): array
44
    {
45
        return $this->results;
46
    }
47
}
48