XRL  3.0.0
Simple XML-RPC Library (both client and server)
BigInteger.php
1 <?php
2 /*
3  * This file is part of XRL, a simple XML-RPC Library for PHP.
4  *
5  * Copyright (c) 2012, XRL Team. All rights reserved.
6  * XRL is licensed under the 3-clause BSD License.
7  *
8  * For the full copyright and license information, please view the LICENSE
9  * file that was distributed with this source code.
10  */
11 
12 namespace fpoirotte\XRL\Types;
13 
23 {
25  const XMLRPC_TYPE = '{http://ws.apache.org/xmlrpc/namespaces/extensions}biginteger';
26 
28  public function set($value)
29  {
30  // Versions before PHP 5.6 used resources to represent big numbers
31  // while new versions use objects instead.
32  if ((is_resource($value) && get_resource_type($value) === 'GMP integer') ||
33  ($value instanceof \GMP)) {
34  // It is already a GMP integer.
35  } else {
36  $value = @gmp_init($value, 10);
37  }
38  if ($value === false) {
39  throw new \InvalidArgumentException("Expected a big integer value");
40  }
41 
42  $this->value = $value;
43  }
44 }
$value
Current value associated with this object.
The XML-RPC "i8" type.
Definition: BigInteger.php:22
const XMLRPC_TYPE
XML-RPC type for this class.
Definition: BigInteger.php:25
Abstract class for fixed-length integer types.