Debian Codegraph @

lib/3rdParty/composer/nesbot/carbon/src/Carbon/Exceptions/OutOfRangeException.php

raw symbols SCIP
1 <?php
2
3 declare(strict_types=1);
4
5 /**
6 * This file is part of the Carbon package.
7 *
8 * (c) Brian Nesbitt <[email protected]>
9 *
10 * For the full copyright and license information, please view the LICENSE
11 * file that was distributed with this source code.
12 */
13
14 namespace Carbon\Exceptions;
15
16 use InvalidArgumentException as BaseInvalidArgumentException;
17 use Throwable;
18
19 // This will extends OutOfRangeException instead of InvalidArgumentException since 3.0.0
20 // use OutOfRangeException as BaseOutOfRangeException;
21
22 class OutOfRangeException extends BaseInvalidArgumentException implements InvalidArgumentException
23 {
24 /**
25 * The unit or name of the value.
26 *
27 * @var string
28 */
29 private $unit;
30
31 /**
32 * The range minimum.
33 *
34 * @var mixed
35 */
36 private $min;
37
38 /**
39 * The range maximum.
40 *
41 * @var mixed
42 */
43 private $max;
44
45 /**
46 * The invalid value.
47 *
48 * @var mixed
49 */
50 private $value;
51
52 /**
53 * Constructor.
54 *
55 * @param string $unit
56 * @param mixed $min
57 * @param mixed $max
58 * @param mixed $value
59 * @param int $code
60 * @param Throwable|null $previous
61 */
62 public function __construct($unit, $min, $max, $value, $code = 0, ?Throwable $previous = null)
63 {
64 $this->unit = $unit;
65 $this->min = $min;
66 $this->max = $max;
67 $this->value = $value;
68
69 parent::__construct("$unit must be between $min and $max, $value given", $code, $previous);
70 }
71
72 /**
73 * @return mixed
74 */
75 public function getMax()
76 {
77 return $this->max;
78 }
79
80 /**
81 * @return mixed
82 */
83 public function getMin()
84 {
85 return $this->min;
86 }
87
88 /**
89 * @return mixed
90 */
91 public function getUnit()
92 {
93 return $this->unit;
94 }
95
96 /**
97 * @return mixed
98 */
99 public function getValue()
100 {
101 return $this->value;
102 }
103 }