Passed
Push — extract-store ( 38a23e...9fc033 )
by Konrad
05:01
created

KeyValueBag::has()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 1
Metric Value
cc 1
eloc 1
nc 1
nop 1
dl 0
loc 3
ccs 2
cts 2
cp 1
crap 1
rs 10
c 1
b 0
f 1
1
<?php
2
3
namespace sweetrdf\InMemoryStoreSqlite;
4
5
/**
6
 * This class acts as a simple key-value cache to speed up insert into operations.
7
 */
8
final class KeyValueBag
9
{
10
    private array $bag = [];
11
12 45
    public function set(string $key, array $value): void
13
    {
14 45
        $this->bag[$key] = $value;
15 45
    }
16
17 76
    public function get(string $key): array | null
0 ignored issues
show
Bug introduced by
The type sweetrdf\InMemoryStoreSqlite\null was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
18
    {
19 76
        return $this->bag[$key] ?? null;
0 ignored issues
show
Bug Best Practice introduced by
The expression return $this->bag[$key] ?? null could return the type null which is incompatible with the type-hinted return array|sweetrdf\InMemoryStoreSqlite\null. Consider adding an additional type-check to rule them out.
Loading history...
20
    }
21
22 75
    public function has(string $key): bool
23
    {
24 75
        return null !== $this->get($key);
25
    }
26
27 2
    public function hasEntries(): bool
28
    {
29 2
        return 0 < \count($this->bag);
30
    }
31
32 10
    public function reset(): void
33
    {
34 10
        $this->bag = [];
35 10
    }
36
}
37