1
<?php
2

3
declare(strict_types=1);
4

5
namespace Kreait\Firebase\RemoteConfig;
6

7
use Kreait\Firebase\Util\DT;
8

9
final class Version
10
{
11
    /** @var VersionNumber */
12
    private $versionNumber;
13

14
    /** @var User */
15
    private $user;
16

17
    /** @var \DateTimeImmutable */
18
    private $updatedAt;
19

20
    /** @var string */
21
    private $description;
22

23
    /** @var UpdateOrigin */
24
    private $updateOrigin;
25

26
    /** @var UpdateType */
27
    private $updateType;
28

29
    /** @var VersionNumber|null */
30
    private $rollbackSource;
31

32 3
    private function __construct()
33
    {
34
    }
35

36
    /**
37
     * @internal
38
     *
39
     * @param array<string, mixed> $data
40
     */
41 3
    public static function fromArray(array $data): self
42
    {
43 3
        $new = new self();
44 3
        $new->versionNumber = VersionNumber::fromValue($data['versionNumber']);
45 3
        $new->user = User::fromArray($data['updateUser']);
46 3
        $new->updatedAt = DT::toUTCDateTimeImmutable($data['updateTime']);
47 3
        $new->description = $data['description'] ?? '';
48

49 3
        $new->updateOrigin = ($data['updateOrigin'] ?? null)
50 3
            ? UpdateOrigin::fromValue($data['updateOrigin'])
51 0
            : UpdateOrigin::fromValue(UpdateOrigin::UNSPECIFIED);
52

53 3
        $new->updateType = ($data['updateType'] ?? null)
54 3
            ? UpdateType::fromValue($data['updateType'])
55 0
            : UpdateType::fromValue(UpdateType::UNSPECIFIED);
56

57 3
        $new->rollbackSource = ($data['rollbackSource'] ?? null)
58 3
            ? VersionNumber::fromValue($data['rollbackSource'])
59 3
            : null;
60

61 3
        return $new;
62
    }
63

64 3
    public function versionNumber(): VersionNumber
65
    {
66 3
        return $this->versionNumber;
67
    }
68

69 0
    public function user(): User
70
    {
71 0
        return $this->user;
72
    }
73

74 3
    public function updatedAt(): \DateTimeImmutable
75
    {
76 3
        return $this->updatedAt;
77
    }
78

79 0
    public function description(): string
80
    {
81 0
        return $this->description;
82
    }
83

84 0
    public function updateOrigin(): UpdateOrigin
85
    {
86 0
        return $this->updateOrigin;
87
    }
88

89 3
    public function updateType(): UpdateType
90
    {
91 3
        return $this->updateType;
92
    }
93

94 3
    public function rollbackSource(): ?VersionNumber
95
    {
96 3
        return $this->rollbackSource;
97
    }
98
}

Read our documentation on viewing source code .

Loading