PluginProbe
WCPOS – Point of Sale (POS) plugin for WooCommerce / 1.10.20
WCPOS – Point of Sale (POS) plugin for WooCommerce v1.10.20
1.10.20 1.10.19 1.10.18 1.10.17 1.10.16 1.10.15 1.10.13 1.10.14 1.10.12 1.10.11 1.10.10 1.10.9 1.10.8 untagged-3d9b7ccddc54df87c672 1.10.7 1.10.6 1.10.5 1.10.3 1.10.4 1.10.2 1.10.1 1.10.0 1.9.17 1.9.15 1.9.16 All 164 releases
woocommerce-pos / vendor_prefixed / guzzlehttp / psr7 / src / Integers.php

Integers.php in WCPOS – Point of Sale (POS) plugin for WooCommerce 1.10.20, at vendor_prefixed/guzzlehttp/psr7/src/Integers.php

87 lines 2.6 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 declare (strict_types=1);
4 namespace WCPOS\Vendor\GuzzleHttp\Psr7;
5
6 /**
7 * @internal
8 */
9 final class Integers
10 {
11 private function __construct()
12 {
13 }
14 public static function add(int $a, int $b) : int
15 {
16 if ($a < 0 || $b < 0) {
17 throw new \InvalidArgumentException('Integer operands must be non-negative');
18 }
19 if ($b > \PHP_INT_MAX - $a) {
20 throw new \OverflowException('Stream byte count exceeds the maximum integer size supported on this platform');
21 }
22 return $a + $b;
23 }
24 public static function addSigned(int $base, int $delta) : int
25 {
26 if ($base < 0) {
27 throw new \InvalidArgumentException('Stream offset must be non-negative');
28 }
29 if ($delta > 0 && $delta > \PHP_INT_MAX - $base) {
30 throw new \OverflowException('Stream offset exceeds the maximum integer size supported on this platform');
31 }
32 $value = $base + $delta;
33 if ($value < 0) {
34 // A negative computed offset is a seek failure at runtime, so throw
35 // RuntimeException per PSR-7, unlike the precondition check above.
36 throw new \RuntimeException('Stream offset must be non-negative');
37 }
38 return $value;
39 }
40 /**
41 * @param mixed $value
42 */
43 public static function assertEngineInteger($value, string $what) : ?int
44 {
45 if ($value === \false || $value === null) {
46 return null;
47 }
48 if (!\is_int($value) || $value < 0) {
49 throw new \OverflowException($what . ' exceeds the maximum integer size supported on this platform');
50 }
51 return $value;
52 }
53 /**
54 * @param mixed $value
55 */
56 public static function assertOptionalNonNegativeSize($value, string $name) : ?int
57 {
58 if ($value === null) {
59 return null;
60 }
61 if (!\is_int($value) || $value < 0) {
62 throw new \InvalidArgumentException($name . ' must be a non-negative integer or null');
63 }
64 return $value;
65 }
66 /**
67 * @param mixed $value
68 */
69 public static function assertNonNegativeInteger($value, string $name) : int
70 {
71 if (!\is_int($value) || $value < 0) {
72 throw new \InvalidArgumentException($name . ' must be a non-negative integer');
73 }
74 return $value;
75 }
76 /**
77 * @param mixed $value
78 */
79 public static function assertLimitInteger($value, string $name) : int
80 {
81 if (!\is_int($value) || $value < -1) {
82 throw new \InvalidArgumentException($name . ' must be -1 or a non-negative integer');
83 }
84 return $value;
85 }
86 }
87