PluginProbe
Defender Security – Malware Scanner, Login Security & Firewall / 5.3.1
Defender Security – Malware Scanner, Login Security & Firewall v5.3.1
6.3.0 6.2.3 6.2.4 6.2.0 6.2.1 6.2.2 6.1.0 5.3.1 5.4.0 5.4.1 5.5.0 5.5.1 5.6.0 5.6.1 5.6.2 5.7.0 5.7.1 5.7.2 5.8.0 5.8.1 5.9.0 6.0.0 6.0.1 3.0.1 3.1.0 All 141 releases
defender-security / vendor / web-auth / metadata-service / src / Version.php

Version.php in Defender Security – Malware Scanner, Login Security & Firewall 5.3.1, at vendor/web-auth/metadata-service/src/Version.php

81 lines 1.8 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 declare(strict_types=1);
4
5 /*
6 * The MIT License (MIT)
7 *
8 * Copyright (c) 2014-2021 Spomky-Labs
9 *
10 * This software may be modified and distributed under the terms
11 * of the MIT license. See the LICENSE file for details.
12 */
13
14 namespace Webauthn\MetadataService;
15
16 use function array_key_exists;
17 use Assert\Assertion;
18 use JsonSerializable;
19 use LogicException;
20 use function Safe\sprintf;
21
22 class Version implements JsonSerializable
23 {
24 /**
25 * @var int|null
26 */
27 private $major;
28
29 /**
30 * @var int|null
31 */
32 private $minor;
33
34 public function __construct(?int $major, ?int $minor)
35 {
36 if (null === $major && null === $minor) {
37 throw new LogicException('Invalid data. Must contain at least one item');
38 }
39 Assertion::greaterOrEqualThan($major, 0, Utils::logicException('Invalid argument "major"'));
40 Assertion::greaterOrEqualThan($minor, 0, Utils::logicException('Invalid argument "minor"'));
41
42 $this->major = $major;
43 $this->minor = $minor;
44 }
45
46 public function getMajor(): ?int
47 {
48 return $this->major;
49 }
50
51 public function getMinor(): ?int
52 {
53 return $this->minor;
54 }
55
56 public static function createFromArray(array $data): self
57 {
58 $data = Utils::filterNullValues($data);
59 foreach (['major', 'minor'] as $key) {
60 if (array_key_exists($key, $data)) {
61 Assertion::integer($data[$key], sprintf('Invalid value for key "%s"', $key));
62 }
63 }
64
65 return new self(
66 $data['major'] ?? null,
67 $data['minor'] ?? null
68 );
69 }
70
71 public function jsonSerialize(): array
72 {
73 $data = [
74 'major' => $this->major,
75 'minor' => $this->minor,
76 ];
77
78 return Utils::filterNullValues($data);
79 }
80 }
81