Debian Codegraph @

vendor/ramsey/uuid/src/Converter/Number/DegradedNumberConverter.php

raw
1 <?php
2 /**
3 * This file is part of the ramsey/uuid library
4 *
5 * For the full copyright and license information, please view the LICENSE
6 * file that was distributed with this source code.
7 *
8 * @copyright Copyright (c) Ben Ramsey <[email protected]>
9 * @license http://opensource.org/licenses/MIT MIT
10 * @link https://benramsey.com/projects/ramsey-uuid/ Documentation
11 * @link https://packagist.org/packages/ramsey/uuid Packagist
12 * @link https://github.com/ramsey/uuid GitHub
13 */
14
15 namespace Ramsey\Uuid\Converter\Number;
16
17 use Ramsey\Uuid\Exception\UnsatisfiedDependencyException;
18 use Ramsey\Uuid\Converter\NumberConverterInterface;
19
20 /**
21 * DegradedNumberConverter throws `UnsatisfiedDependencyException` exceptions
22 * if attempting to use number conversion functionality in an environment that
23 * does not support large integers (i.e. when moontoast/math is not available)
24 */
25 class DegradedNumberConverter implements NumberConverterInterface
26 {
27 /**
28 * Throws an `UnsatisfiedDependencyException`
29 *
30 * @param string $hex The hexadecimal string representation to convert
31 * @return void
32 * @throws UnsatisfiedDependencyException
33 */
34 public function fromHex($hex)
35 {
36 throw new UnsatisfiedDependencyException(
37 'Cannot call ' . __METHOD__ . ' without support for large '
38 . 'integers, since integer is an unsigned '
39 . '128-bit integer; Moontoast\Math\BigNumber is required.'
40 );
41 }
42
43 /**
44 * Throws an `UnsatisfiedDependencyException`
45 *
46 * @param mixed $integer An integer representation to convert
47 * @return void
48 * @throws UnsatisfiedDependencyException
49 */
50 public function toHex($integer)
51 {
52 throw new UnsatisfiedDependencyException(
53 'Cannot call ' . __METHOD__ . ' without support for large '
54 . 'integers, since integer is an unsigned '
55 . '128-bit integer; Moontoast\Math\BigNumber is required. '
56 );
57 }
58 }