• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

brick / math / 21788758024

07 Feb 2026 11:34PM UTC coverage: 98.544% (-0.8%) from 99.37%
21788758024

push

github

BenMorel
Add fast-path optimizations

3 of 3 new or added lines in 1 file covered. (100.0%)

14 existing lines in 4 files now uncovered.

1354 of 1374 relevant lines covered (98.54%)

2270.88 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

71.43
/src/Exception/InvalidArgumentException.php
1
<?php
2

3
declare(strict_types=1);
4

5
namespace Brick\Math\Exception;
6

7
use Brick\Math\Internal\Constants;
8

9
use function sprintf;
10

11
/**
12
 * Exception thrown when an invalid argument is provided.
13
 */
14
final class InvalidArgumentException extends \InvalidArgumentException implements MathException
15
{
16
    /**
17
     * @pure
18
     */
19
    public static function baseOutOfRange(int $base): InvalidArgumentException
20
    {
21
        return new self(sprintf('Base %d is out of range [2, 36].', $base));
30✔
22
    }
23

24
    /**
25
     * @pure
26
     */
27
    public static function exponentOutOfRange(int $exponent, int $min, int $max): InvalidArgumentException
28
    {
29
        return new self(sprintf(
18✔
30
            'Exponent %d is out of range [%d, %d].',
18✔
31
            $exponent,
18✔
32
            $min,
18✔
33
            $max,
18✔
34
        ));
18✔
35
    }
36

37
    /**
38
     * @pure
39
     */
40
    public static function negativeScale(): InvalidArgumentException
41
    {
42
        return new self('The scale must not be negative.');
6✔
43
    }
44

45
    /**
46
     * @pure
47
     */
48
    public static function negativeBitIndex(): InvalidArgumentException
49
    {
50
        return new self('The bit index must not be negative.');
3✔
51
    }
52

53
    /**
54
     * @pure
55
     */
56
    public static function negativeBitCount(): InvalidArgumentException
57
    {
58
        return new self('The bit count must not be negative.');
3✔
59
    }
60

61
    /**
62
     * @pure
63
     */
64
    public static function alphabetTooShort(): InvalidArgumentException
65
    {
66
        return new self('The alphabet must contain at least 2 characters.');
12✔
67
    }
68

69
    /**
70
     * @pure
71
     */
72
    public static function duplicateCharsInAlphabet(): InvalidArgumentException
73
    {
74
        return new self('The alphabet must not contain duplicate characters.');
18✔
75
    }
76

77
    /**
78
     * @pure
79
     */
80
    public static function minGreaterThanMax(): InvalidArgumentException
81
    {
82
        return new self('The minimum value must be less than or equal to the maximum value.');
12✔
83
    }
84

85
    /**
86
     * @pure
87
     */
88
    public static function negativeExponent(): InvalidArgumentException
89
    {
90
        return new self('The exponent must not be negative.');
3✔
91
    }
92

93
    /**
94
     * @pure
95
     */
96
    public static function negativeModulus(): InvalidArgumentException
97
    {
98
        return new self('The modulus must be strictly positive.');
9✔
99
    }
100

101
    /**
102
     * @pure
103
     */
104
    public static function bitShiftOutOfRange(int $bits): InvalidArgumentException
105
    {
UNCOV
106
        return new self(sprintf(
×
UNCOV
107
            'Bit shift %d is out of range [%d, %d].',
×
UNCOV
108
            $bits,
×
UNCOV
109
            -Constants::MAX_BIT_SHIFT,
×
UNCOV
110
            Constants::MAX_BIT_SHIFT,
×
UNCOV
111
        ));
×
112
    }
113
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc