FixedKeys   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 19
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 9
dl 0
loc 19
rs 10
c 0
b 0
f 0
wmc 3

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A nextKey() 0 7 2
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Damax\Media\Domain\Storage\Keys;
6
7
class FixedKeys implements Keys
8
{
9
    private $keys;
10
    private $count;
11
    private $index = 0;
12
13
    public function __construct(array $keys)
14
    {
15
        $this->keys = $keys;
16
        $this->count = count($keys);
17
    }
18
19
    public function nextKey($context = []): string
20
    {
21
        $key = $this->keys[$this->index];
22
23
        $this->index = $this->index + 1 === $this->count ? 0 : $this->index + 1;
24
25
        return $key;
26
    }
27
}
28