Passed
Push — ft/pagefield ( db2ad6...f2722b )
by Ben
10:27
created

FieldReference::getFragmentKey()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 1
c 1
b 0
f 0
dl 0
loc 3
rs 10
cc 1
nc 1
nop 0
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Thinktomorrow\Chief\Fields;
6
7
class FieldReference
8
{
9
    /** @var string */
10
    private $managerKey;
11
12
    /** @var string */
13
    private $fieldKey;
14
15
    /** @var string */
16
    private $fragmentKey;
17
18
    public function __construct(string $managerKey, string $fieldKey, string $fragmentKey = null)
19
    {
20
        $this->managerKey = $managerKey;
21
        $this->fieldKey = $fieldKey;
22
        $this->fragmentKey = $fragmentKey;
23
    }
24
25
    public function getManagerKey(): string
26
    {
27
        return $this->managerKey;
28
    }
29
30
    public function getFieldKey(): string
31
    {
32
        return $this->fieldKey;
33
    }
34
35
    public function getFragmentKey(): ?string
36
    {
37
        return $this->fragmentKey;
38
    }
39
40
    public function hasFragmentKey(): bool
41
    {
42
        return isset($this->fragmentKey);
43
    }
44
45
    public function toArray(): array
46
    {
47
        return [
48
            'managerKey'  => $this->managerKey,
49
            'fieldKey'    => $this->fieldKey,
50
            'fragmentKey' => $this->fragmentKey,
51
        ];
52
    }
53
}
54