LoggableContextCollection::getByClass()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 1
c 0
b 0
f 0
nc 1
nop 1
dl 0
loc 3
rs 10
1
<?php
2
3
namespace Locastic\Loggastic\Metadata\LoggableContext;
4
5
final class LoggableContextCollection implements \IteratorAggregate, \Countable
6
{
7
    public function __construct(private readonly array $loggableContextCollection = [])
8
    {
9
    }
10
11
    public function getByClass(string $loggableClass): ?array
12
    {
13
        return $this->getIterator()[$loggableClass] ?? null;
14
    }
15
16
    /**
17
     * {@inheritdoc}
18
     *
19
     * @return \Traversable<string>
20
     */
21
    public function getIterator(): \Traversable
22
    {
23
        return new \ArrayIterator($this->loggableContextCollection);
24
    }
25
26
    /**
27
     * {@inheritdoc}
28
     */
29
    public function count(): int
30
    {
31
        return \count($this->loggableContextCollection);
32
    }
33
}
34