-
-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathLicense.php
More file actions
94 lines (72 loc) · 1.7 KB
/
License.php
File metadata and controls
94 lines (72 loc) · 1.7 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
<?php declare(strict_types = 1);
namespace Contributte\OpenApi\Schema;
class License
{
private string $name;
private ?string $identifier = null;
private ?string $url = null;
private ?VendorExtensions $vendorExtensions = null;
public function __construct(string $name)
{
$this->name = $name;
}
/**
* @param array{name: string, identifier?: string, url?: string} $data
*/
public static function fromArray(array $data): License
{
$license = new License($data['name']);
$license->setIdentifier($data['identifier'] ?? null);
$license->setUrl($data['url'] ?? null);
$license->setVendorExtensions(VendorExtensions::fromArray($data));
return $license;
}
/**
* @return mixed[]
*/
public function toArray(): array
{
$data = [];
$data['name'] = $this->name;
// Optional SPDX identifier
if ($this->identifier !== null) {
$data['identifier'] = $this->identifier;
}
// Optional url
if ($this->url !== null) {
$data['url'] = $this->url;
}
if ($this->vendorExtensions !== null) {
$data = array_merge($data, $this->vendorExtensions->toArray());
}
return $data;
}
public function setIdentifier(?string $identifier): void
{
$this->identifier = $identifier;
}
public function setUrl(?string $url): void
{
$this->url = $url;
}
public function getName(): string
{
return $this->name;
}
public function getIdentifier(): ?string
{
return $this->identifier;
}
public function getUrl(): ?string
{
return $this->url;
}
public function getVendorExtensions(): ?VendorExtensions
{
return $this->vendorExtensions;
}
public function setVendorExtensions(?VendorExtensions $vendorExtensions): void
{
$this->vendorExtensions = $vendorExtensions;
}
}