forked from appwrite/appwrite
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCompose.php
More file actions
73 lines (61 loc) 路 1.54 KB
/
Copy pathCompose.php
File metadata and controls
73 lines (61 loc) 路 1.54 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
<?php
namespace Appwrite\Docker;
use Appwrite\Docker\Compose\Service;
use Exception;
class Compose
{
/**
* @var array
*/
protected $compose = [];
/**
* @var string $data
*/
public function __construct(string $data)
{
$this->compose = yaml_parse($data);
$this->compose['services'] = (isset($this->compose['services']) && is_array($this->compose['services']))
? $this->compose['services'] : [];
foreach ($this->compose['services'] as $key => &$service) {
$service = new Service($service);
}
}
/**
* @return string
*/
public function getVersion(): string
{
return (isset($this->compose['version'])) ? $this->compose['version'] : '';
}
/**
* @return Service[]
*/
public function getServices(): array
{
return $this->compose['services'];
}
/**
* @return Service
*/
public function getService(string $name): Service
{
if (!isset($this->compose['services'][$name])) {
throw new Exception('Service not found');
}
return $this->compose['services'][$name];
}
/**
* @return array
*/
public function getNetworks(): array
{
return (isset($this->compose['networks'])) ? array_keys($this->compose['networks']) : [];
}
/**
* @return array
*/
public function getVolumes(): array
{
return (isset($this->compose['volumes'])) ? array_keys($this->compose['volumes']) : [];
}
}