Debian Codegraph @

vendor/ramsey/uuid/src/Math/CalculatorInterface.php

raw
1 <?php
2
3 /**
4 * This file is part of the ramsey/uuid library
5 *
6 * For the full copyright and license information, please view the LICENSE
7 * file that was distributed with this source code.
8 *
9 * @copyright Copyright (c) Ben Ramsey <[email protected]>
10 * @license http://opensource.org/licenses/MIT MIT
11 */
12
13 declare(strict_types=1);
14
15 namespace Ramsey\Uuid\Math;
16
17 use Ramsey\Uuid\Type\Hexadecimal;
18 use Ramsey\Uuid\Type\Integer as IntegerObject;
19 use Ramsey\Uuid\Type\NumberInterface;
20
21 /**
22 * A calculator performs arithmetic operations on numbers
23 *
24 * @immutable
25 */
26 interface CalculatorInterface
27 {
28 /**
29 * Returns the sum of all the provided parameters
30 *
31 * @param NumberInterface $augend The first addend (the integer being added to)
32 * @param NumberInterface ...$addends The additional integers to a add to the augend
33 *
34 * @return NumberInterface The sum of all the parameters
35 *
36 * @pure
37 */
38 public function add(NumberInterface $augend, NumberInterface ...$addends): NumberInterface;
39
40 /**
41 * Returns the difference of all the provided parameters
42 *
43 * @param NumberInterface $minuend The integer being subtracted from
44 * @param NumberInterface ...$subtrahends The integers to subtract from the minuend
45 *
46 * @return NumberInterface The difference after subtracting all parameters
47 *
48 * @pure
49 */
50 public function subtract(NumberInterface $minuend, NumberInterface ...$subtrahends): NumberInterface;
51
52 /**
53 * Returns the product of all the provided parameters
54 *
55 * @param NumberInterface $multiplicand The integer to be multiplied
56 * @param NumberInterface ...$multipliers The factors by which to multiply the multiplicand
57 *
58 * @return NumberInterface The product of multiplying all the provided parameters
59 *
60 * @pure
61 */
62 public function multiply(NumberInterface $multiplicand, NumberInterface ...$multipliers): NumberInterface;
63
64 /**
65 * Returns the quotient of the provided parameters divided left-to-right
66 *
67 * @param int $roundingMode The RoundingMode constant to use for this operation
68 * @param int<0, max> $scale The scale to use for this operation
69 * @param NumberInterface $dividend The integer to be divided
70 * @param NumberInterface ...$divisors The integers to divide $dividend by, in the order in which the division
71 * operations should take place (left-to-right)
72 *
73 * @return NumberInterface The quotient of dividing the provided parameters left-to-right
74 *
75 * @pure
76 */
77 public function divide(
78 int $roundingMode,
79 int $scale,
80 NumberInterface $dividend,
81 NumberInterface ...$divisors,
82 ): NumberInterface;
83
84 /**
85 * Converts a value from an arbitrary base to a base-10 integer value
86 *
87 * @param non-empty-string $value The value to convert
88 * @param int<2, 36> $base The base to convert from (i.e., 2, 16, 32, etc.)
89 *
90 * @return IntegerObject The base-10 integer value of the converted value
91 *
92 * @pure
93 */
94 public function fromBase(string $value, int $base): IntegerObject;
95
96 /**
97 * Converts a base-10 integer value to an arbitrary base
98 *
99 * @param IntegerObject $value The integer value to convert
100 * @param int<2, 36> $base The base to convert to (i.e., 2, 16, 32, etc.)
101 *
102 * @return string The value represented in the specified base
103 *
104 * @pure
105 */
106 public function toBase(IntegerObject $value, int $base): string;
107
108 /**
109 * Converts an Integer instance to a Hexadecimal instance
110 *
111 * @pure
112 */
113 public function toHexadecimal(IntegerObject $value): Hexadecimal;
114
115 /**
116 * Converts a Hexadecimal instance to an Integer instance
117 *
118 * @pure
119 */
120 public function toInteger(Hexadecimal $value): IntegerObject;
121 }