LoggableContextCollection   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 27
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 4
c 0
b 0
f 0
dl 0
loc 27
rs 10
wmc 4

4 Methods

Rating   Name   Duplication   Size   Complexity  
A getIterator() 0 3 1
A __construct() 0 2 1
A getByClass() 0 3 1
A count() 0 3 1
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