|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
declare(strict_types=1); |
|
4
|
|
|
|
|
5
|
|
|
namespace MaxBeckers\AmazonAlexa\Response\Directives\APL\Document; |
|
6
|
|
|
|
|
7
|
|
|
class Import implements \JsonSerializable |
|
8
|
|
|
{ |
|
9
|
|
|
/** |
|
10
|
|
|
* @param string $name Package name property |
|
11
|
|
|
* @param string $version Package version property |
|
12
|
|
|
* @param string|null $accept Package accept property (APL 2024.3 and later) |
|
13
|
|
|
* @param string[]|null $loadAfter List of import names this import should load after |
|
14
|
|
|
* @param string|null $source Optional package source property |
|
15
|
|
|
* @param ImportType|null $type Polymorphic type property |
|
16
|
|
|
* @param bool $when When false, ignore this import |
|
17
|
|
|
*/ |
|
18
|
16 |
|
public function __construct( |
|
19
|
|
|
public string $name, |
|
20
|
|
|
public string $version, |
|
21
|
|
|
public ?string $accept = null, |
|
22
|
|
|
public ?array $loadAfter = null, |
|
23
|
|
|
public ?string $source = null, |
|
24
|
|
|
public ?ImportType $type = null, |
|
25
|
|
|
public bool $when = true, |
|
26
|
|
|
) { |
|
27
|
16 |
|
} |
|
28
|
|
|
|
|
29
|
12 |
|
public function jsonSerialize(): array |
|
30
|
|
|
{ |
|
31
|
12 |
|
$data = [ |
|
32
|
12 |
|
'name' => $this->name, |
|
33
|
12 |
|
'version' => $this->version, |
|
34
|
12 |
|
]; |
|
35
|
|
|
|
|
36
|
12 |
|
if ($this->accept !== null && $this->accept !== '') { |
|
37
|
2 |
|
$data['accept'] = $this->accept; |
|
38
|
|
|
} |
|
39
|
12 |
|
if ($this->loadAfter !== null && $this->loadAfter !== []) { |
|
40
|
2 |
|
$data['loadAfter'] = $this->loadAfter; |
|
41
|
|
|
} |
|
42
|
12 |
|
if ($this->source !== null && $this->source !== '') { |
|
43
|
2 |
|
$data['source'] = $this->source; |
|
44
|
|
|
} |
|
45
|
12 |
|
if ($this->type !== null) { |
|
46
|
2 |
|
$data['type'] = $this->type->value; |
|
47
|
|
|
} |
|
48
|
12 |
|
if (!$this->when) { |
|
49
|
2 |
|
$data['when'] = $this->when; |
|
50
|
|
|
} |
|
51
|
|
|
|
|
52
|
12 |
|
return $data; |
|
53
|
|
|
} |
|
54
|
|
|
} |
|
55
|
|
|
|