Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
100.00% covered (success)
100.00%
16 / 16
100.00% covered (success)
100.00%
5 / 5
CRAP
100.00% covered (success)
100.00%
1 / 1
ConfigKeyStruct
100.00% covered (success)
100.00%
16 / 16
100.00% covered (success)
100.00%
5 / 5
9
100.00% covered (success)
100.00%
1 / 1
 __construct
100.00% covered (success)
100.00%
12 / 12
100.00% covered (success)
100.00%
1 / 1
5
 getOriginalKey
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 getAnlass
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 getDataIdentifier
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 getParts
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
1<?php declare(strict_types=1);
2
3namespace Satag\AmicronEntityBundle\Util\PlattformKonfig;
4
5class ConfigKeyStruct
6{
7    private readonly string $anlass;
8
9    private readonly string $dataIdentifier;
10
11    /**
12     * @var string[]
13     */
14    private array $parts;
15
16    public function __construct(
17        private readonly string $originalKey
18    ) {
19        $parts = explode('.', $originalKey);
20        if (\count($parts) < 2) {
21            throw new ConfigKeyStructException(\sprintf("Ungültiger Schlüssel (%s) min. 2 Stufen\r\n", $originalKey));
22        }
23        $this->anlass = trim($parts[0]);
24        if ($this->anlass === '') {
25            throw new ConfigKeyStructException(\sprintf("Ungültiger Schlüssel (%s) min. 2 Stufen\r\n", $originalKey));
26        }
27        $this->dataIdentifier = trim($parts[1]);
28        if ($this->dataIdentifier === '') {
29            throw new ConfigKeyStructException(\sprintf("Ungültiger Schlüssel (%s) min. 2 Stufen\r\n", $originalKey));
30        }
31        if (\count($parts) === 2) {
32            $this->parts = [];
33        } else {
34            $this->parts = array_splice($parts, 2);
35        }
36    }
37
38    public function getOriginalKey(): string
39    {
40        return $this->originalKey;
41    }
42
43    public function getAnlass(): string
44    {
45        return $this->anlass;
46    }
47
48    public function getDataIdentifier(): string
49    {
50        return $this->dataIdentifier;
51    }
52
53    /**
54     * @return string[]
55     */
56    public function getParts(): array
57    {
58        return $this->parts;
59    }
60}