| 1 | <?php |
||
| 7 | abstract class AbstractMySqlIntegerCase extends AbstractIntegerCase |
||
| 8 | { |
||
| 9 | /** |
||
| 10 | * Indicates if the integer is signed. |
||
| 11 | * |
||
| 12 | * @var bool |
||
| 13 | */ |
||
| 14 | protected $signed; |
||
| 15 | |||
| 16 | /** |
||
| 17 | * @param bool $signed Indicates if the value is signed. For MySql 5.7, integers are signed by default. |
||
| 18 | */ |
||
| 19 | 183 | public function __construct(bool $signed = true) |
|
| 23 | |||
| 24 | /** |
||
| 25 | * Return the minimum allowed Signed value. |
||
| 26 | * |
||
| 27 | * @return int|float |
||
| 28 | */ |
||
| 29 | abstract protected function minSignedValue(); |
||
| 30 | |||
| 31 | /** |
||
| 32 | * Return the maximum allowed Signed value. |
||
| 33 | * |
||
| 34 | * @return int|float |
||
| 35 | */ |
||
| 36 | abstract protected function maxSignedValue(); |
||
| 37 | |||
| 38 | /** |
||
| 39 | * Return the minimum allowed Unsigned value. |
||
| 40 | * |
||
| 41 | * @return int|float |
||
| 42 | */ |
||
| 43 | abstract protected function minUnSignedValue(); |
||
| 44 | |||
| 45 | /** |
||
| 46 | * Return the maximum allowed Unsigned value. |
||
| 47 | * |
||
| 48 | * @return int|float |
||
| 49 | */ |
||
| 50 | abstract protected function maxUnsignedValue(); |
||
| 51 | |||
| 52 | /** |
||
| 53 | * Ensures that the field's value is a valid Mysql standard int. |
||
| 54 | * |
||
| 55 | * @param object $subject |
||
| 56 | * @param string $field |
||
| 57 | * |
||
| 58 | * @return bool |
||
| 59 | */ |
||
| 60 | 156 | public function __invoke($subject, string $field): bool |
|
| 66 | |||
| 67 | /** |
||
| 68 | * Indicates if the given value is within |
||
| 69 | * |
||
| 70 | * @param int $value |
||
| 71 | * |
||
| 72 | * @return bool |
||
| 73 | */ |
||
| 74 | 174 | protected function isWithinBounds($value): bool |
|
| 82 | } |
||
| 83 |