Subversion-Projekte lars-tiefland.laravel_shop

Revision

Details | Letzte Änderung | Log anzeigen | RSS feed

Revision Autor Zeilennr. Zeile
148 lars 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 <ben@benramsey.com>
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
 * @psalm-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
    public function add(NumberInterface $augend, NumberInterface ...$addends): NumberInterface;
37
 
38
    /**
39
     * Returns the difference of all the provided parameters
40
     *
41
     * @param NumberInterface $minuend The integer being subtracted from
42
     * @param NumberInterface ...$subtrahends The integers to subtract from the minuend
43
     *
44
     * @return NumberInterface The difference after subtracting all parameters
45
     */
46
    public function subtract(NumberInterface $minuend, NumberInterface ...$subtrahends): NumberInterface;
47
 
48
    /**
49
     * Returns the product of all the provided parameters
50
     *
51
     * @param NumberInterface $multiplicand The integer to be multiplied
52
     * @param NumberInterface ...$multipliers The factors by which to multiply the multiplicand
53
     *
54
     * @return NumberInterface The product of multiplying all the provided parameters
55
     */
56
    public function multiply(NumberInterface $multiplicand, NumberInterface ...$multipliers): NumberInterface;
57
 
58
    /**
59
     * Returns the quotient of the provided parameters divided left-to-right
60
     *
61
     * @param int $roundingMode The RoundingMode constant to use for this operation
62
     * @param int $scale The scale to use for this operation
63
     * @param NumberInterface $dividend The integer to be divided
64
     * @param NumberInterface ...$divisors The integers to divide $dividend by, in
65
     *     the order in which the division operations should take place
66
     *     (left-to-right)
67
     *
68
     * @return NumberInterface The quotient of dividing the provided parameters left-to-right
69
     */
70
    public function divide(
71
        int $roundingMode,
72
        int $scale,
73
        NumberInterface $dividend,
74
        NumberInterface ...$divisors
75
    ): NumberInterface;
76
 
77
    /**
78
     * Converts a value from an arbitrary base to a base-10 integer value
79
     *
80
     * @param string $value The value to convert
81
     * @param int $base The base to convert from (i.e., 2, 16, 32, etc.)
82
     *
83
     * @return IntegerObject The base-10 integer value of the converted value
84
     */
85
    public function fromBase(string $value, int $base): IntegerObject;
86
 
87
    /**
88
     * Converts a base-10 integer value to an arbitrary base
89
     *
90
     * @param IntegerObject $value The integer value to convert
91
     * @param int $base The base to convert to (i.e., 2, 16, 32, etc.)
92
     *
93
     * @return string The value represented in the specified base
94
     */
95
    public function toBase(IntegerObject $value, int $base): string;
96
 
97
    /**
98
     * Converts an Integer instance to a Hexadecimal instance
99
     */
100
    public function toHexadecimal(IntegerObject $value): Hexadecimal;
101
 
102
    /**
103
     * Converts a Hexadecimal instance to an Integer instance
104
     */
105
    public function toInteger(Hexadecimal $value): IntegerObject;
106
}