ILIAS  release_5-1 Revision 5.0.0-5477-g43f3e3fab5f
Boolean.php
Go to the documentation of this file.
1<?php
2
3/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4 foldmethod=marker: */
4
5// LICENSE AGREEMENT. If folded, press za here to unfold and read license {{{
6
40// }}}
41
42// dependencies {{{
43require_once 'XML/RPC2/Exception.php';
44require_once 'XML/RPC2/Backend/Php/Value/Scalar.php';
45// }}}
46
58{
59
60 // {{{ constructor
61
67 public function __construct($nativeValue)
68 {
69 parent::__construct('boolean', $nativeValue);
70 }
71
72 // }}}
73 // {{{ encode()
74
80 public function encode()
81 {
82 return '<boolean>' . ($this->getNativeValue() ? 1 : 0). '</boolean>';
83 }
84
85 // }}}
86 // {{{ decode()
87
93 public static function decode($xml)
94 {
95 // TODO Remove reparsing of XML fragment, when SimpleXML proves more solid. Currently it segfaults when
96 // xpath is used both in an element and in one of its children
97 $xml = simplexml_load_string($xml->asXML());
98 $value = $xml->xpath('/value/boolean/text()');
99
100 // Double cast explanation: http://pear.php.net/bugs/bug.php?id=8644
101 return (boolean) ((string) $value[0]);
102 }
103
104 // }}}
105
106}
107
108?>
__construct($nativeValue)
Constructor.
Definition: Boolean.php:67
static decode($xml)
decode.
Definition: Boolean.php:93
encode()
Encode the instance into XML, for transport.
Definition: Boolean.php:80
getNativeValue()
nativeValue property getter
Definition: Value.php:76