Issues (9)

src/Formatter/BaseConfig.php (1 issue)

Labels
Severity
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Inspirum\XML\Formatter;
6
7
abstract readonly class BaseConfig implements Config
0 ignored issues
show
A parse error occurred: Syntax error, unexpected T_READONLY, expecting T_CLASS on line 7 at column 9
Loading history...
8
{
9
    private const ATTRIBUTES = '@attributes';
10
    private const NODES = '@nodes';
11
    private const VALUE = '@value';
12
    private const FLATTEN_NODES = '/';
13
    private const FLATTEN_ATTRIBUTES = '@';
14
15
    /**
16
     * @param list<string>|true $alwaysArray
17
     */
18 20
    public function __construct(
19
        private array|true $alwaysArray = [],
20
        private bool $autoCast = false,
21
        private ?string $attributesName = null,
22
        private ?string $valueName = null,
23
    ) {
24 20
    }
25
26 17
    public function isAlwaysArray(): bool
27
    {
28 17
        return $this->alwaysArray === true;
29
    }
30
31
    /**
32
     * @inheritDoc
33
     */
34 15
    public function getAlwaysArrayNodeNames(): array
35
    {
36 15
        if ($this->alwaysArray === true) {
37
            return [];
38
        }
39
40 15
        return $this->alwaysArray;
41
    }
42
43 19
    public function isAutoCast(): bool
44
    {
45 19
        return $this->autoCast;
46
    }
47
48 14
    public function isFullResponse(): bool
49
    {
50 14
        return false;
51
    }
52
53 13
    public function getAttributesName(): string
54
    {
55 13
        return $this->attributesName ?? self::ATTRIBUTES;
56
    }
57
58 10
    public function getValueName(): string
59
    {
60 10
        return $this->valueName ?? self::VALUE;
61
    }
62
63 1
    public function getNodesName(): string
64
    {
65 1
        return self::NODES;
66
    }
67
68 12
    public function isFlatten(): bool
69
    {
70 12
        return false;
71
    }
72
73 4
    public function getFlattenNodes(): string
74
    {
75 4
        return self::FLATTEN_NODES;
76
    }
77
78 4
    public function getFlattenAttributes(): string
79
    {
80 4
        return self::FLATTEN_ATTRIBUTES;
81
    }
82
83
    public function isWithoutRoot(): bool
84
    {
85
        return false;
86
    }
87
}
88