glpi / src / plugins / vigilo / Vigilo / VigiloDepends.php @ 8d255750
History | View | Annotate | Download (856 Bytes)
1 |
<?php
|
---|---|
2 |
|
3 |
class VigiloDepends extends VigiloXml |
4 |
{ |
5 |
protected $host; |
6 |
protected $service; |
7 |
|
8 |
public function __construct($host = null, $service = null) |
9 |
{ |
10 |
if (null === $host && null === $service) { |
11 |
throw new Exception('Invalid dependency'); |
12 |
} |
13 |
|
14 |
if ('' === $host || '' === $service || !is_string($host) || !is_string($service)) { |
15 |
throw new Exception('Invalid dependency'); |
16 |
} |
17 |
|
18 |
$this->host = $host; |
19 |
$this->service = $service; |
20 |
} |
21 |
|
22 |
public function __toString() |
23 |
{ |
24 |
if (null === $this->host) { |
25 |
return "<depends service=\"{$this->service}\"/>"; |
26 |
} |
27 |
|
28 |
if (null === $this->service) { |
29 |
return "<depends host=\"{$this->host}\"/>"; |
30 |
} |
31 |
|
32 |
return "<depends host=\"{$this->host}\" service=\"{$this->service}\"/>"; |
33 |
} |
34 |
} |