diff options
author | David <david@xagasoft.com> | 2011-03-14 19:57:11 +0000 |
---|---|---|
committer | David <david@xagasoft.com> | 2011-03-14 19:57:11 +0000 |
commit | b4573698043c4ad972f7e80e84d0a88af373a53d (patch) | |
tree | f88124a83a68dcf651d3209c025fbeb0a491cb6e /php/phpgats.php | |
parent | 0b31b494fd157296e5b59bd1fb20c9e627fec3c3 (diff) | |
download | libgats-b4573698043c4ad972f7e80e84d0a88af373a53d.tar.gz libgats-b4573698043c4ad972f7e80e84d0a88af373a53d.tar.bz2 libgats-b4573698043c4ad972f7e80e84d0a88af373a53d.tar.xz libgats-b4573698043c4ad972f7e80e84d0a88af373a53d.zip |
david - phpgats_Integer handles various types a little better now...
Diffstat (limited to '')
-rw-r--r-- | php/phpgats.php | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/php/phpgats.php b/php/phpgats.php index 10008aa..188dbc0 100644 --- a/php/phpgats.php +++ b/php/phpgats.php | |||
@@ -155,10 +155,19 @@ class phpgats_Integer extends phpgats_Element | |||
155 | 155 | ||
156 | function __construct( $_elem ) | 156 | function __construct( $_elem ) |
157 | { | 157 | { |
158 | if( getType($_elem) != "resource" ) | 158 | if( $_elem === '' ) |
159 | $this->elem = gmp_init(0); | ||
160 | else if( getType($_elem) == "resource" ) | ||
161 | $this->elem = $_elem; | ||
162 | else if( getType($_elem) == "string" ) | ||
159 | $this->elem = gmp_init($_elem); | 163 | $this->elem = gmp_init($_elem); |
164 | else if( getType($_elem) == "integer" ) | ||
165 | $this->elem = gmp_init($_elem+0); | ||
166 | else if( getType($_elem) == "double" ) | ||
167 | $this->elem = gmp_init(intval($_elem)); | ||
160 | else | 168 | else |
161 | $this->elem = $_elem; | 169 | throw new Exception("Bad phpgats_Integer type: '" . |
170 | getType($_elem) . "'."); | ||
162 | } | 171 | } |
163 | 172 | ||
164 | function set( $_elem ) | 173 | function set( $_elem ) |