PageRenderTime 24ms CodeModel.GetById 16ms app.highlight 4ms RepoModel.GetById 1ms app.codeStats 1ms

/class/libraries/vendor/ircmaxell/security-lib/lib/SecurityLib/BigMath.php

https://gitlab.com/VoyaTrax/vtCMS2
PHP | 65 lines | 15 code | 5 blank | 45 comment | 2 complexity | d6b19de3a052d944c83f5151f35b315b MD5 | raw file
 1<?php
 2/**
 3 * A class for arbitrary precision math functions
 4 *
 5 * PHP version 5.3
 6 *
 7 * @category   PHPPasswordLib
 8 * @package    Core
 9 * @author     Anthony Ferrara <ircmaxell@ircmaxell.com>
10 * @copyright  2011 The Authors
11 * @license    http://www.opensource.org/licenses/mit-license.html  MIT License
12 * @version    Build @@version@@
13 */
14namespace SecurityLib;
15
16/**
17 * A class for arbitrary precision math functions
18 *
19 * @category   PHPPasswordLib
20 * @package    Core
21 * @author     Anthony Ferrara <ircmaxell@ircmaxell.com>
22 */
23abstract class BigMath {
24
25    /**
26     * Get an instance of the big math class
27     *
28     * This is NOT a singleton.  It simply loads the proper strategy
29     * given the current server configuration
30     *
31     * @return \PasswordLib\Core\BigMath A big math instance
32     */
33    public static function createFromServerConfiguration() {
34        //@codeCoverageIgnoreStart
35        if (extension_loaded('gmp')) {
36            return new \SecurityLib\BigMath\GMP();
37        } elseif (extension_loaded('bcmath')) {
38            return new \SecurityLib\BigMath\BCMath();
39        } else {
40            return new \SecurityLib\BigMath\PHPMath();
41        }
42        //@codeCoverageIgnoreEnd
43    }
44
45    /**
46     * Add two numbers together
47     *
48     * @param string $left  The left argument
49     * @param string $right The right argument
50     *
51     * @return A base-10 string of the sum of the two arguments
52     */
53    abstract public function add($left, $right);
54
55    /**
56     * Subtract two numbers
57     *
58     * @param string $left  The left argument
59     * @param string $right The right argument
60     *
61     * @return A base-10 string of the difference of the two arguments
62     */
63    abstract public function subtract($left, $right);
64
65}