1 | <?php |
||
30 | class Iq extends Stanza |
||
31 | { |
||
32 | /** |
||
33 | * Stanza constructor. |
||
34 | * @param string $type Iq query type |
||
35 | * @param array $options { |
||
36 | * @var Jid $from Jid representing "from" stanza attribute |
||
37 | * @var Jid $to Jid representing "to" stanza attribute |
||
38 | * @var string $id Unique id, will be generated if omitted |
||
39 | * @var string $type Stanza type |
||
40 | * @var mixed $content Stanza content |
||
41 | * @var array $arguments Stanza arguments |
||
42 | * @var Query $query Query associated with stanza |
||
43 | * } |
||
44 | */ |
||
45 | 3 | public function __construct(string $type, array $options = []) |
|
46 | { |
||
47 | 3 | $this->type = $type; |
|
48 | 3 | parent::__construct('iq', $options); |
|
49 | 3 | } |
|
50 | |||
51 | 3 | protected function appendChild($element) |
|
52 | { |
||
53 | 3 | if(count($this->children) > 0) { |
|
54 | throw new \RuntimeException('Iq stanzas cannot have more than one child.'); |
||
55 | } |
||
56 | |||
57 | 3 | return parent::appendChild($element); |
|
58 | } |
||
59 | |||
60 | #region Query |
||
61 | /** |
||
62 | * @return Query |
||
63 | */ |
||
64 | 3 | public function getQuery() |
|
65 | { |
||
66 | 3 | return $this->get(Query::class); |
|
|
|||
67 | } |
||
68 | |||
69 | /** |
||
70 | * @param Query $query |
||
71 | */ |
||
72 | 3 | public function setQuery(Query $query) |
|
73 | { |
||
74 | 3 | $this->remove($this->query); |
|
75 | 3 | $this->append($query); |
|
76 | 3 | } |
|
77 | #endregion |
||
78 | |||
79 | public static function getXmlCollocations() : array |
||
86 | } |
||
87 |