From b4573698043c4ad972f7e80e84d0a88af373a53d Mon Sep 17 00:00:00 2001 From: David Date: Mon, 14 Mar 2011 19:57:11 +0000 Subject: david - phpgats_Integer handles various types a little better now... --- php/phpgats.php | 13 +++++++++++-- 1 file 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 function __construct( $_elem ) { - if( getType($_elem) != "resource" ) + if( $_elem === '' ) + $this->elem = gmp_init(0); + else if( getType($_elem) == "resource" ) + $this->elem = $_elem; + else if( getType($_elem) == "string" ) $this->elem = gmp_init($_elem); + else if( getType($_elem) == "integer" ) + $this->elem = gmp_init($_elem+0); + else if( getType($_elem) == "double" ) + $this->elem = gmp_init(intval($_elem)); else - $this->elem = $_elem; + throw new Exception("Bad phpgats_Integer type: '" . + getType($_elem) . "'."); } function set( $_elem ) -- cgit v1.2.3