create-prisma-php-app 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (610) hide show
  1. package/LICENSE.txt +9 -0
  2. package/README.md +158 -0
  3. package/composer.json +23 -0
  4. package/composer.lock +812 -0
  5. package/dist/bootstrap.php +4 -0
  6. package/dist/index.js +2 -0
  7. package/dist/node_modules/prisma-client-php/index.enc +1 -0
  8. package/dist/node_modules/prisma-client-php/index.js +2 -0
  9. package/dist/node_modules/prisma-client-php/key.enc +1 -0
  10. package/dist/node_modules/prisma-client-php/package.json +7 -0
  11. package/dist/prisma/schema.prisma +32 -0
  12. package/dist/prisma/seed.js +68 -0
  13. package/dist/public/assets/images/prisma-php.png +0 -0
  14. package/dist/public/css/styles.css +0 -0
  15. package/dist/public/css/tailwind.css +3 -0
  16. package/dist/public/favicon.ico +0 -0
  17. package/dist/public/index.php +64 -0
  18. package/dist/settings/paths.php +10 -0
  19. package/dist/settings/project-settings.js +6 -0
  20. package/dist/src/app/api/api.php +39 -0
  21. package/dist/src/app/classes/Validator.php +77 -0
  22. package/dist/src/app/model/IModel.php +22 -0
  23. package/package.json +35 -0
  24. package/tsconfig.json +110 -0
  25. package/vendor/autoload.php +25 -0
  26. package/vendor/brick/math/.editorconfig +15 -0
  27. package/vendor/brick/math/.gitattributes +11 -0
  28. package/vendor/brick/math/.github/FUNDING.yml +1 -0
  29. package/vendor/brick/math/.github/workflows/ci.yml +80 -0
  30. package/vendor/brick/math/CHANGELOG.md +445 -0
  31. package/vendor/brick/math/LICENSE +20 -0
  32. package/vendor/brick/math/README.md +247 -0
  33. package/vendor/brick/math/composer.json +34 -0
  34. package/vendor/brick/math/phpunit.php +51 -0
  35. package/vendor/brick/math/phpunit.xml +13 -0
  36. package/vendor/brick/math/psalm.xml +28 -0
  37. package/vendor/brick/math/random-tests.php +162 -0
  38. package/vendor/brick/math/src/BigDecimal.php +786 -0
  39. package/vendor/brick/math/src/BigInteger.php +1079 -0
  40. package/vendor/brick/math/src/BigNumber.php +512 -0
  41. package/vendor/brick/math/src/BigRational.php +445 -0
  42. package/vendor/brick/math/src/Exception/DivisionByZeroException.php +35 -0
  43. package/vendor/brick/math/src/Exception/IntegerOverflowException.php +23 -0
  44. package/vendor/brick/math/src/Exception/MathException.php +12 -0
  45. package/vendor/brick/math/src/Exception/NegativeNumberException.php +12 -0
  46. package/vendor/brick/math/src/Exception/NumberFormatException.php +33 -0
  47. package/vendor/brick/math/src/Exception/RoundingNecessaryException.php +19 -0
  48. package/vendor/brick/math/src/Internal/Calculator/BcMathCalculator.php +75 -0
  49. package/vendor/brick/math/src/Internal/Calculator/GmpCalculator.php +108 -0
  50. package/vendor/brick/math/src/Internal/Calculator/NativeCalculator.php +581 -0
  51. package/vendor/brick/math/src/Internal/Calculator.php +676 -0
  52. package/vendor/brick/math/src/RoundingMode.php +107 -0
  53. package/vendor/brick/math/tests/AbstractTestCase.php +86 -0
  54. package/vendor/brick/math/tests/BigDecimalTest.php +2596 -0
  55. package/vendor/brick/math/tests/BigIntegerTest.php +3782 -0
  56. package/vendor/brick/math/tests/BigNumberTest.php +53 -0
  57. package/vendor/brick/math/tests/BigRationalTest.php +993 -0
  58. package/vendor/brick/math/tests/CalculatorDetectTest.php +25 -0
  59. package/vendor/brick/math/tests/Internal/Calculator/NativeCalculatorTest.php +87 -0
  60. package/vendor/composer/ClassLoader.php +579 -0
  61. package/vendor/composer/InstalledVersions.php +359 -0
  62. package/vendor/composer/LICENSE +21 -0
  63. package/vendor/composer/autoload_classmap.php +15 -0
  64. package/vendor/composer/autoload_files.php +13 -0
  65. package/vendor/composer/autoload_namespaces.php +9 -0
  66. package/vendor/composer/autoload_psr4.php +20 -0
  67. package/vendor/composer/autoload_real.php +50 -0
  68. package/vendor/composer/autoload_static.php +122 -0
  69. package/vendor/composer/installed.json +825 -0
  70. package/vendor/composer/installed.php +132 -0
  71. package/vendor/composer/platform_check.php +26 -0
  72. package/vendor/firebase/php-jwt/.gitattributes +9 -0
  73. package/vendor/firebase/php-jwt/.github/release-please.yml +3 -0
  74. package/vendor/firebase/php-jwt/.github/workflows/tests.yml +57 -0
  75. package/vendor/firebase/php-jwt/.php-cs-fixer.dist.php +24 -0
  76. package/vendor/firebase/php-jwt/CHANGELOG.md +170 -0
  77. package/vendor/firebase/php-jwt/LICENSE +30 -0
  78. package/vendor/firebase/php-jwt/README.md +424 -0
  79. package/vendor/firebase/php-jwt/composer.json +42 -0
  80. package/vendor/firebase/php-jwt/phpstan.neon.dist +5 -0
  81. package/vendor/firebase/php-jwt/phpunit.xml.dist +18 -0
  82. package/vendor/firebase/php-jwt/src/BeforeValidException.php +18 -0
  83. package/vendor/firebase/php-jwt/src/CachedKeySet.php +268 -0
  84. package/vendor/firebase/php-jwt/src/ExpiredException.php +18 -0
  85. package/vendor/firebase/php-jwt/src/JWK.php +349 -0
  86. package/vendor/firebase/php-jwt/src/JWT.php +669 -0
  87. package/vendor/firebase/php-jwt/src/JWTExceptionWithPayloadInterface.php +20 -0
  88. package/vendor/firebase/php-jwt/src/Key.php +64 -0
  89. package/vendor/firebase/php-jwt/src/SignatureInvalidException.php +7 -0
  90. package/vendor/firebase/php-jwt/tests/CachedKeySetTest.php +598 -0
  91. package/vendor/firebase/php-jwt/tests/JWKTest.php +172 -0
  92. package/vendor/firebase/php-jwt/tests/JWTTest.php +543 -0
  93. package/vendor/firebase/php-jwt/tests/data/ec-jwkset.json +40 -0
  94. package/vendor/firebase/php-jwt/tests/data/ecdsa-private.pem +18 -0
  95. package/vendor/firebase/php-jwt/tests/data/ecdsa-public.pem +9 -0
  96. package/vendor/firebase/php-jwt/tests/data/ecdsa256-private.pem +4 -0
  97. package/vendor/firebase/php-jwt/tests/data/ecdsa384-private.pem +6 -0
  98. package/vendor/firebase/php-jwt/tests/data/ecdsa384-public.pem +5 -0
  99. package/vendor/firebase/php-jwt/tests/data/ed25519-1.pub +1 -0
  100. package/vendor/firebase/php-jwt/tests/data/ed25519-1.sec +1 -0
  101. package/vendor/firebase/php-jwt/tests/data/ed25519-jwkset.json +11 -0
  102. package/vendor/firebase/php-jwt/tests/data/rsa-jwkset.json +18 -0
  103. package/vendor/firebase/php-jwt/tests/data/rsa-with-passphrase.pem +42 -0
  104. package/vendor/firebase/php-jwt/tests/data/rsa1-private.pem +27 -0
  105. package/vendor/firebase/php-jwt/tests/data/rsa1-public.pub +9 -0
  106. package/vendor/firebase/php-jwt/tests/data/rsa2-private.pem +27 -0
  107. package/vendor/firebase/php-jwt/tests/data/secp256k1-private.pem +5 -0
  108. package/vendor/firebase/php-jwt/tests/data/secp256k1-public.pem +4 -0
  109. package/vendor/graham-campbell/result-type/.gitattributes +9 -0
  110. package/vendor/graham-campbell/result-type/.github/CODE_OF_CONDUCT.md +132 -0
  111. package/vendor/graham-campbell/result-type/.github/CONTRIBUTING.md +31 -0
  112. package/vendor/graham-campbell/result-type/.github/FUNDING.yml +2 -0
  113. package/vendor/graham-campbell/result-type/.github/SECURITY.md +14 -0
  114. package/vendor/graham-campbell/result-type/.github/workflows/tests.yml +40 -0
  115. package/vendor/graham-campbell/result-type/CHANGELOG.md +43 -0
  116. package/vendor/graham-campbell/result-type/LICENSE +21 -0
  117. package/vendor/graham-campbell/result-type/README.md +42 -0
  118. package/vendor/graham-campbell/result-type/composer.json +33 -0
  119. package/vendor/graham-campbell/result-type/phpunit.xml.dist +13 -0
  120. package/vendor/graham-campbell/result-type/src/Error.php +121 -0
  121. package/vendor/graham-campbell/result-type/src/Result.php +69 -0
  122. package/vendor/graham-campbell/result-type/src/Success.php +120 -0
  123. package/vendor/graham-campbell/result-type/tests/ResultTest.php +95 -0
  124. package/vendor/hidehalo/nanoid-php/.editorconfig +15 -0
  125. package/vendor/hidehalo/nanoid-php/.gitattributes +8 -0
  126. package/vendor/hidehalo/nanoid-php/.github/workflows/php.yml +49 -0
  127. package/vendor/hidehalo/nanoid-php/.styleci.yml +1 -0
  128. package/vendor/hidehalo/nanoid-php/CHANGELOG.md +36 -0
  129. package/vendor/hidehalo/nanoid-php/CODE_OF_CONDUCT.md +74 -0
  130. package/vendor/hidehalo/nanoid-php/CONTRIBUTING.md +32 -0
  131. package/vendor/hidehalo/nanoid-php/ISSUE_TEMPLATE.md +27 -0
  132. package/vendor/hidehalo/nanoid-php/LICENSE.md +21 -0
  133. package/vendor/hidehalo/nanoid-php/PULL_REQUEST_TEMPLATE.md +43 -0
  134. package/vendor/hidehalo/nanoid-php/README.md +108 -0
  135. package/vendor/hidehalo/nanoid-php/benchmark/benchmark.php +24 -0
  136. package/vendor/hidehalo/nanoid-php/composer.json +62 -0
  137. package/vendor/hidehalo/nanoid-php/examples/basic_usage.php +24 -0
  138. package/vendor/hidehalo/nanoid-php/examples/custom_formated.php +29 -0
  139. package/vendor/hidehalo/nanoid-php/phpunit.xml +31 -0
  140. package/vendor/hidehalo/nanoid-php/src/Client.php +120 -0
  141. package/vendor/hidehalo/nanoid-php/src/Core.php +31 -0
  142. package/vendor/hidehalo/nanoid-php/src/CoreInterface.php +19 -0
  143. package/vendor/hidehalo/nanoid-php/src/Generator.php +13 -0
  144. package/vendor/hidehalo/nanoid-php/src/GeneratorInterface.php +13 -0
  145. package/vendor/hidehalo/nanoid-php/tests/ClientTest.php +76 -0
  146. package/vendor/hidehalo/nanoid-php/tests/CoreTest.php +37 -0
  147. package/vendor/hidehalo/nanoid-php/tests/GeneratorTest.php +34 -0
  148. package/vendor/hidehalo/nanoid-php/tests/Support/DummyGenerator.php +20 -0
  149. package/vendor/paragonie/random_compat/.gitattributes +14 -0
  150. package/vendor/paragonie/random_compat/.scrutinizer.yml +4 -0
  151. package/vendor/paragonie/random_compat/.travis.yml +59 -0
  152. package/vendor/paragonie/random_compat/CHANGELOG.md +3 -0
  153. package/vendor/paragonie/random_compat/LICENSE +22 -0
  154. package/vendor/paragonie/random_compat/RATIONALE.md +36 -0
  155. package/vendor/paragonie/random_compat/README.md +232 -0
  156. package/vendor/paragonie/random_compat/SECURITY.md +108 -0
  157. package/vendor/paragonie/random_compat/build-phar.sh +5 -0
  158. package/vendor/paragonie/random_compat/composer.json +34 -0
  159. package/vendor/paragonie/random_compat/dist/random_compat.phar.pubkey +5 -0
  160. package/vendor/paragonie/random_compat/dist/random_compat.phar.pubkey.asc +11 -0
  161. package/vendor/paragonie/random_compat/lib/random.php +32 -0
  162. package/vendor/paragonie/random_compat/other/build_phar.php +57 -0
  163. package/vendor/paragonie/random_compat/other/ide_stubs/COM.php +20 -0
  164. package/vendor/paragonie/random_compat/other/ide_stubs/README.md +7 -0
  165. package/vendor/paragonie/random_compat/other/ide_stubs/com_exception.php +11 -0
  166. package/vendor/paragonie/random_compat/other/ide_stubs/libsodium.php +90 -0
  167. package/vendor/paragonie/random_compat/phpunit.sh +60 -0
  168. package/vendor/paragonie/random_compat/phpunit.xml.dist +31 -0
  169. package/vendor/paragonie/random_compat/psalm-autoload.php +9 -0
  170. package/vendor/paragonie/random_compat/psalm.xml +19 -0
  171. package/vendor/paragonie/random_compat/tests/full/DieHardTest.php +61 -0
  172. package/vendor/paragonie/random_compat/tests/full/StatTest.php +52 -0
  173. package/vendor/paragonie/random_compat/tests/specific/capicom.php +7 -0
  174. package/vendor/paragonie/random_compat/tests/specific/dev_urandom.php +7 -0
  175. package/vendor/paragonie/random_compat/tests/specific/libsodium.php +7 -0
  176. package/vendor/paragonie/random_compat/tests/specific/libsodium_legacy.php +7 -0
  177. package/vendor/paragonie/random_compat/tests/specific/mcrypt.php +7 -0
  178. package/vendor/paragonie/random_compat/tests/unit/RandomBytesTest.php +80 -0
  179. package/vendor/paragonie/random_compat/tests/unit/RandomIntTest.php +63 -0
  180. package/vendor/paragonie/random_compat/tests/unit/UtilityTest.php +95 -0
  181. package/vendor/paragonie/random_compat/tests/unit_with_basedir/RandomBytesTest.php +100 -0
  182. package/vendor/paragonie/random_compat/tests/unit_with_basedir/RandomIntTest.php +82 -0
  183. package/vendor/paragonie/random_compat/tests/unit_with_basedir/UtilityTest.php +95 -0
  184. package/vendor/phpoption/phpoption/.gitattributes +14 -0
  185. package/vendor/phpoption/phpoption/.github/CODE_OF_CONDUCT.md +132 -0
  186. package/vendor/phpoption/phpoption/.github/CONTRIBUTING.md +30 -0
  187. package/vendor/phpoption/phpoption/.github/FUNDING.yml +2 -0
  188. package/vendor/phpoption/phpoption/.github/SECURITY.md +14 -0
  189. package/vendor/phpoption/phpoption/.github/workflows/static.yml +74 -0
  190. package/vendor/phpoption/phpoption/.github/workflows/tests.yml +40 -0
  191. package/vendor/phpoption/phpoption/LICENSE +201 -0
  192. package/vendor/phpoption/phpoption/Makefile +26 -0
  193. package/vendor/phpoption/phpoption/README.md +194 -0
  194. package/vendor/phpoption/phpoption/composer.json +52 -0
  195. package/vendor/phpoption/phpoption/phpstan-baseline.neon +32 -0
  196. package/vendor/phpoption/phpoption/phpstan.neon.dist +8 -0
  197. package/vendor/phpoption/phpoption/phpunit.xml.dist +13 -0
  198. package/vendor/phpoption/phpoption/psalm.xml +12 -0
  199. package/vendor/phpoption/phpoption/src/PhpOption/LazyOption.php +175 -0
  200. package/vendor/phpoption/phpoption/src/PhpOption/None.php +136 -0
  201. package/vendor/phpoption/phpoption/src/PhpOption/Option.php +434 -0
  202. package/vendor/phpoption/phpoption/src/PhpOption/Some.php +169 -0
  203. package/vendor/phpoption/phpoption/tests/PhpOption/Tests/EnsureTest.php +77 -0
  204. package/vendor/phpoption/phpoption/tests/PhpOption/Tests/LazyOptionTest.php +200 -0
  205. package/vendor/phpoption/phpoption/tests/PhpOption/Tests/NoneTest.php +153 -0
  206. package/vendor/phpoption/phpoption/tests/PhpOption/Tests/OptionTest.php +160 -0
  207. package/vendor/phpoption/phpoption/tests/PhpOption/Tests/SomeTest.php +194 -0
  208. package/vendor/phpoption/phpoption/tests/bootstrap.php +8 -0
  209. package/vendor/phpoption/phpoption/vendor-bin/phpstan/composer.json +8 -0
  210. package/vendor/phpoption/phpoption/vendor-bin/psalm/composer.json +8 -0
  211. package/vendor/ramsey/uuid/.editorconfig +16 -0
  212. package/vendor/ramsey/uuid/.gitattributes +26 -0
  213. package/vendor/ramsey/uuid/.github/CODEOWNERS +1 -0
  214. package/vendor/ramsey/uuid/.github/FUNDING.yml +2 -0
  215. package/vendor/ramsey/uuid/.github/ISSUE_TEMPLATE/Bug_Report.md +35 -0
  216. package/vendor/ramsey/uuid/.github/ISSUE_TEMPLATE/Feature_Request.md +31 -0
  217. package/vendor/ramsey/uuid/.github/ISSUE_TEMPLATE/Question.md +19 -0
  218. package/vendor/ramsey/uuid/.github/ISSUE_TEMPLATE/config.yml +1 -0
  219. package/vendor/ramsey/uuid/.github/dependabot.yml +15 -0
  220. package/vendor/ramsey/uuid/.github/pull_request_template.md +27 -0
  221. package/vendor/ramsey/uuid/.github/workflows/continuous-integration.yml +181 -0
  222. package/vendor/ramsey/uuid/.github/workflows/merge-dependabot-upgrades.yml +24 -0
  223. package/vendor/ramsey/uuid/.readthedocs.yml +11 -0
  224. package/vendor/ramsey/uuid/CHANGELOG.md +1511 -0
  225. package/vendor/ramsey/uuid/CODE_OF_CONDUCT.md +73 -0
  226. package/vendor/ramsey/uuid/CONTRIBUTING.md +171 -0
  227. package/vendor/ramsey/uuid/LICENSE +19 -0
  228. package/vendor/ramsey/uuid/README.md +83 -0
  229. package/vendor/ramsey/uuid/SECURITY.md +170 -0
  230. package/vendor/ramsey/uuid/build/.gitignore +6 -0
  231. package/vendor/ramsey/uuid/build/cache/.gitkeep +0 -0
  232. package/vendor/ramsey/uuid/build/logs/.gitkeep +0 -0
  233. package/vendor/ramsey/uuid/captainhook.json +105 -0
  234. package/vendor/ramsey/uuid/codecov.yml +29 -0
  235. package/vendor/ramsey/uuid/composer.json +106 -0
  236. package/vendor/ramsey/uuid/composer.lock +7208 -0
  237. package/vendor/ramsey/uuid/docs/Makefile +20 -0
  238. package/vendor/ramsey/uuid/docs/README.md +36 -0
  239. package/vendor/ramsey/uuid/docs/_static/.gitkeep +0 -0
  240. package/vendor/ramsey/uuid/docs/conf.py +103 -0
  241. package/vendor/ramsey/uuid/docs/copyright.rst +18 -0
  242. package/vendor/ramsey/uuid/docs/customize/calculators.rst +75 -0
  243. package/vendor/ramsey/uuid/docs/customize/factory.rst +93 -0
  244. package/vendor/ramsey/uuid/docs/customize/ordered-time-codec.rst +86 -0
  245. package/vendor/ramsey/uuid/docs/customize/timestamp-first-comb-codec.rst +72 -0
  246. package/vendor/ramsey/uuid/docs/customize/validators.rst +39 -0
  247. package/vendor/ramsey/uuid/docs/customize.rst +56 -0
  248. package/vendor/ramsey/uuid/docs/database.rst +260 -0
  249. package/vendor/ramsey/uuid/docs/faq.rst +132 -0
  250. package/vendor/ramsey/uuid/docs/index.rst +51 -0
  251. package/vendor/ramsey/uuid/docs/introduction.rst +31 -0
  252. package/vendor/ramsey/uuid/docs/nonstandard/guid.rst +152 -0
  253. package/vendor/ramsey/uuid/docs/nonstandard/other.rst +49 -0
  254. package/vendor/ramsey/uuid/docs/nonstandard/version6.rst +17 -0
  255. package/vendor/ramsey/uuid/docs/nonstandard.rst +40 -0
  256. package/vendor/ramsey/uuid/docs/quickstart.rst +112 -0
  257. package/vendor/ramsey/uuid/docs/reference/calculators.rst +168 -0
  258. package/vendor/ramsey/uuid/docs/reference/exceptions.rst +92 -0
  259. package/vendor/ramsey/uuid/docs/reference/fields-fieldsinterface.rst +16 -0
  260. package/vendor/ramsey/uuid/docs/reference/guid-fields.rst +13 -0
  261. package/vendor/ramsey/uuid/docs/reference/guid-guid.rst +20 -0
  262. package/vendor/ramsey/uuid/docs/reference/helper.rst +62 -0
  263. package/vendor/ramsey/uuid/docs/reference/name-based-namespaces.rst +31 -0
  264. package/vendor/ramsey/uuid/docs/reference/nonstandard-fields.rst +13 -0
  265. package/vendor/ramsey/uuid/docs/reference/nonstandard-uuid.rst +20 -0
  266. package/vendor/ramsey/uuid/docs/reference/nonstandard-uuidv6.rst +34 -0
  267. package/vendor/ramsey/uuid/docs/reference/rfc4122-fieldsinterface.rst +78 -0
  268. package/vendor/ramsey/uuid/docs/reference/rfc4122-uuidinterface.rst +20 -0
  269. package/vendor/ramsey/uuid/docs/reference/rfc4122-uuidv1.rst +21 -0
  270. package/vendor/ramsey/uuid/docs/reference/rfc4122-uuidv2.rst +47 -0
  271. package/vendor/ramsey/uuid/docs/reference/rfc4122-uuidv3.rst +13 -0
  272. package/vendor/ramsey/uuid/docs/reference/rfc4122-uuidv4.rst +13 -0
  273. package/vendor/ramsey/uuid/docs/reference/rfc4122-uuidv5.rst +13 -0
  274. package/vendor/ramsey/uuid/docs/reference/rfc4122-uuidv6.rst +31 -0
  275. package/vendor/ramsey/uuid/docs/reference/rfc4122-uuidv7.rst +20 -0
  276. package/vendor/ramsey/uuid/docs/reference/rfc4122-uuidv8.rst +13 -0
  277. package/vendor/ramsey/uuid/docs/reference/rfc4122-version.rst +87 -0
  278. package/vendor/ramsey/uuid/docs/reference/timebaseduuidinterface.rst +16 -0
  279. package/vendor/ramsey/uuid/docs/reference/types.rst +79 -0
  280. package/vendor/ramsey/uuid/docs/reference/uuid.rst +161 -0
  281. package/vendor/ramsey/uuid/docs/reference/uuidfactoryinterface.rst +102 -0
  282. package/vendor/ramsey/uuid/docs/reference/uuidinterface.rst +60 -0
  283. package/vendor/ramsey/uuid/docs/reference/validators.rst +34 -0
  284. package/vendor/ramsey/uuid/docs/reference/variant.rst +32 -0
  285. package/vendor/ramsey/uuid/docs/reference.rst +37 -0
  286. package/vendor/ramsey/uuid/docs/requirements.txt +3 -0
  287. package/vendor/ramsey/uuid/docs/rfc4122/version1.rst +192 -0
  288. package/vendor/ramsey/uuid/docs/rfc4122/version2.rst +273 -0
  289. package/vendor/ramsey/uuid/docs/rfc4122/version3.rst +68 -0
  290. package/vendor/ramsey/uuid/docs/rfc4122/version4.rst +39 -0
  291. package/vendor/ramsey/uuid/docs/rfc4122/version5.rst +108 -0
  292. package/vendor/ramsey/uuid/docs/rfc4122/version6.rst +213 -0
  293. package/vendor/ramsey/uuid/docs/rfc4122/version7.rst +173 -0
  294. package/vendor/ramsey/uuid/docs/rfc4122/version8.rst +51 -0
  295. package/vendor/ramsey/uuid/docs/rfc4122.rst +67 -0
  296. package/vendor/ramsey/uuid/docs/testing.rst +199 -0
  297. package/vendor/ramsey/uuid/docs/tidelift.rst +74 -0
  298. package/vendor/ramsey/uuid/docs/upgrading/2-to-3.rst +31 -0
  299. package/vendor/ramsey/uuid/docs/upgrading/3-to-4.rst +512 -0
  300. package/vendor/ramsey/uuid/docs/upgrading.rst +11 -0
  301. package/vendor/ramsey/uuid/phpbench.json +10 -0
  302. package/vendor/ramsey/uuid/phpcs.xml.dist +476 -0
  303. package/vendor/ramsey/uuid/phpstan-tests.neon +32 -0
  304. package/vendor/ramsey/uuid/phpstan.neon.dist +25 -0
  305. package/vendor/ramsey/uuid/phpunit.xml.dist +26 -0
  306. package/vendor/ramsey/uuid/psalm-baseline.xml +133 -0
  307. package/vendor/ramsey/uuid/psalm.xml +25 -0
  308. package/vendor/ramsey/uuid/resources/vagrant/README.md +10 -0
  309. package/vendor/ramsey/uuid/resources/vagrant/freebsd/README.md +15 -0
  310. package/vendor/ramsey/uuid/resources/vagrant/freebsd/Vagrantfile +35 -0
  311. package/vendor/ramsey/uuid/resources/vagrant/linux/README.md +15 -0
  312. package/vendor/ramsey/uuid/resources/vagrant/linux/Vagrantfile +27 -0
  313. package/vendor/ramsey/uuid/resources/vagrant/windows/README.md +16 -0
  314. package/vendor/ramsey/uuid/resources/vagrant/windows/Vagrantfile +22 -0
  315. package/vendor/ramsey/uuid/src/BinaryUtils.php +106 -0
  316. package/vendor/ramsey/uuid/src/Builder/FallbackBuilder.php +68 -0
  317. package/vendor/ramsey/uuid/src/Builder/UuidBuilderInterface.php +39 -0
  318. package/vendor/ramsey/uuid/src/Codec/CodecInterface.php +67 -0
  319. package/vendor/ramsey/uuid/src/Codec/GuidStringCodec.php +82 -0
  320. package/vendor/ramsey/uuid/src/Codec/OrderedTimeCodec.php +114 -0
  321. package/vendor/ramsey/uuid/src/Codec/StringCodec.php +128 -0
  322. package/vendor/ramsey/uuid/src/Codec/TimestampFirstCombCodec.php +105 -0
  323. package/vendor/ramsey/uuid/src/Codec/TimestampLastCombCodec.php +51 -0
  324. package/vendor/ramsey/uuid/src/Converter/Number/GenericNumberConverter.php +48 -0
  325. package/vendor/ramsey/uuid/src/Converter/NumberConverterInterface.php +53 -0
  326. package/vendor/ramsey/uuid/src/Converter/Time/GenericTimeConverter.php +118 -0
  327. package/vendor/ramsey/uuid/src/Converter/Time/PhpTimeConverter.php +163 -0
  328. package/vendor/ramsey/uuid/src/Converter/Time/UnixTimeConverter.php +90 -0
  329. package/vendor/ramsey/uuid/src/Converter/TimeConverterInterface.php +58 -0
  330. package/vendor/ramsey/uuid/src/Exception/BuilderNotFoundException.php +24 -0
  331. package/vendor/ramsey/uuid/src/Exception/DateTimeException.php +24 -0
  332. package/vendor/ramsey/uuid/src/Exception/DceSecurityException.php +25 -0
  333. package/vendor/ramsey/uuid/src/Exception/InvalidArgumentException.php +24 -0
  334. package/vendor/ramsey/uuid/src/Exception/InvalidBytesException.php +24 -0
  335. package/vendor/ramsey/uuid/src/Exception/InvalidUuidStringException.php +25 -0
  336. package/vendor/ramsey/uuid/src/Exception/NameException.php +25 -0
  337. package/vendor/ramsey/uuid/src/Exception/NodeException.php +24 -0
  338. package/vendor/ramsey/uuid/src/Exception/RandomSourceException.php +27 -0
  339. package/vendor/ramsey/uuid/src/Exception/TimeSourceException.php +24 -0
  340. package/vendor/ramsey/uuid/src/Exception/UnableToBuildUuidException.php +24 -0
  341. package/vendor/ramsey/uuid/src/Exception/UnsupportedOperationException.php +24 -0
  342. package/vendor/ramsey/uuid/src/Exception/UuidExceptionInterface.php +21 -0
  343. package/vendor/ramsey/uuid/src/FeatureSet.php +395 -0
  344. package/vendor/ramsey/uuid/src/Fields/FieldsInterface.php +42 -0
  345. package/vendor/ramsey/uuid/src/Fields/SerializableFieldsTrait.php +70 -0
  346. package/vendor/ramsey/uuid/src/Generator/CombGenerator.php +124 -0
  347. package/vendor/ramsey/uuid/src/Generator/DceSecurityGenerator.php +139 -0
  348. package/vendor/ramsey/uuid/src/Generator/DceSecurityGeneratorInterface.php +53 -0
  349. package/vendor/ramsey/uuid/src/Generator/DefaultNameGenerator.php +51 -0
  350. package/vendor/ramsey/uuid/src/Generator/DefaultTimeGenerator.php +131 -0
  351. package/vendor/ramsey/uuid/src/Generator/NameGeneratorFactory.php +30 -0
  352. package/vendor/ramsey/uuid/src/Generator/NameGeneratorInterface.php +38 -0
  353. package/vendor/ramsey/uuid/src/Generator/PeclUuidNameGenerator.php +52 -0
  354. package/vendor/ramsey/uuid/src/Generator/PeclUuidRandomGenerator.php +37 -0
  355. package/vendor/ramsey/uuid/src/Generator/PeclUuidTimeGenerator.php +39 -0
  356. package/vendor/ramsey/uuid/src/Generator/RandomBytesGenerator.php +45 -0
  357. package/vendor/ramsey/uuid/src/Generator/RandomGeneratorFactory.php +30 -0
  358. package/vendor/ramsey/uuid/src/Generator/RandomGeneratorInterface.php +31 -0
  359. package/vendor/ramsey/uuid/src/Generator/TimeGeneratorFactory.php +45 -0
  360. package/vendor/ramsey/uuid/src/Generator/TimeGeneratorInterface.php +38 -0
  361. package/vendor/ramsey/uuid/src/Generator/UnixTimeGenerator.php +170 -0
  362. package/vendor/ramsey/uuid/src/Guid/Fields.php +208 -0
  363. package/vendor/ramsey/uuid/src/Guid/Guid.php +61 -0
  364. package/vendor/ramsey/uuid/src/Guid/GuidBuilder.php +79 -0
  365. package/vendor/ramsey/uuid/src/Lazy/LazyUuidFromString.php +226 -0
  366. package/vendor/ramsey/uuid/src/Math/BrickMathCalculator.php +145 -0
  367. package/vendor/ramsey/uuid/src/Math/CalculatorInterface.php +106 -0
  368. package/vendor/ramsey/uuid/src/Math/RoundingMode.php +146 -0
  369. package/vendor/ramsey/uuid/src/Nonstandard/Fields.php +154 -0
  370. package/vendor/ramsey/uuid/src/Nonstandard/Uuid.php +37 -0
  371. package/vendor/ramsey/uuid/src/Nonstandard/UuidBuilder.php +78 -0
  372. package/vendor/ramsey/uuid/src/Nonstandard/UuidV6.php +113 -0
  373. package/vendor/ramsey/uuid/src/Provider/Dce/SystemDceSecurityProvider.php +236 -0
  374. package/vendor/ramsey/uuid/src/Provider/DceSecurityProviderInterface.php +41 -0
  375. package/vendor/ramsey/uuid/src/Provider/Node/FallbackNodeProvider.php +54 -0
  376. package/vendor/ramsey/uuid/src/Provider/Node/RandomNodeProvider.php +69 -0
  377. package/vendor/ramsey/uuid/src/Provider/Node/StaticNodeProvider.php +74 -0
  378. package/vendor/ramsey/uuid/src/Provider/Node/SystemNodeProvider.php +190 -0
  379. package/vendor/ramsey/uuid/src/Provider/NodeProviderInterface.php +30 -0
  380. package/vendor/ramsey/uuid/src/Provider/Time/FixedTimeProvider.php +57 -0
  381. package/vendor/ramsey/uuid/src/Provider/Time/SystemTimeProvider.php +33 -0
  382. package/vendor/ramsey/uuid/src/Provider/TimeProviderInterface.php +28 -0
  383. package/vendor/ramsey/uuid/src/Rfc4122/Fields.php +214 -0
  384. package/vendor/ramsey/uuid/src/Rfc4122/FieldsInterface.php +129 -0
  385. package/vendor/ramsey/uuid/src/Rfc4122/MaxTrait.php +41 -0
  386. package/vendor/ramsey/uuid/src/Rfc4122/MaxUuid.php +27 -0
  387. package/vendor/ramsey/uuid/src/Rfc4122/NilTrait.php +41 -0
  388. package/vendor/ramsey/uuid/src/Rfc4122/NilUuid.php +27 -0
  389. package/vendor/ramsey/uuid/src/Rfc4122/TimeTrait.php +55 -0
  390. package/vendor/ramsey/uuid/src/Rfc4122/UuidBuilder.php +116 -0
  391. package/vendor/ramsey/uuid/src/Rfc4122/UuidInterface.php +30 -0
  392. package/vendor/ramsey/uuid/src/Rfc4122/UuidV1.php +61 -0
  393. package/vendor/ramsey/uuid/src/Rfc4122/UuidV2.php +119 -0
  394. package/vendor/ramsey/uuid/src/Rfc4122/UuidV3.php +58 -0
  395. package/vendor/ramsey/uuid/src/Rfc4122/UuidV4.php +58 -0
  396. package/vendor/ramsey/uuid/src/Rfc4122/UuidV5.php +58 -0
  397. package/vendor/ramsey/uuid/src/Rfc4122/UuidV6.php +30 -0
  398. package/vendor/ramsey/uuid/src/Rfc4122/UuidV7.php +63 -0
  399. package/vendor/ramsey/uuid/src/Rfc4122/UuidV8.php +65 -0
  400. package/vendor/ramsey/uuid/src/Rfc4122/Validator.php +45 -0
  401. package/vendor/ramsey/uuid/src/Rfc4122/VariantTrait.php +87 -0
  402. package/vendor/ramsey/uuid/src/Rfc4122/Version.php +139 -0
  403. package/vendor/ramsey/uuid/src/Rfc4122/VersionTrait.php +57 -0
  404. package/vendor/ramsey/uuid/src/TimeBasedUuidFactoryInterface.php +48 -0
  405. package/vendor/ramsey/uuid/src/TimeBasedUuidInterface.php +30 -0
  406. package/vendor/ramsey/uuid/src/Type/Decimal.php +135 -0
  407. package/vendor/ramsey/uuid/src/Type/Hexadecimal.php +109 -0
  408. package/vendor/ramsey/uuid/src/Type/Integer.php +145 -0
  409. package/vendor/ramsey/uuid/src/Type/NumberInterface.php +28 -0
  410. package/vendor/ramsey/uuid/src/Type/Time.php +108 -0
  411. package/vendor/ramsey/uuid/src/Type/TypeInterface.php +45 -0
  412. package/vendor/ramsey/uuid/src/Uuid.php +645 -0
  413. package/vendor/ramsey/uuid/src/UuidFactory.php +503 -0
  414. package/vendor/ramsey/uuid/src/UuidFactoryInterface.php +184 -0
  415. package/vendor/ramsey/uuid/src/UuidInterface.php +114 -0
  416. package/vendor/ramsey/uuid/src/Validator/GenericValidator.php +45 -0
  417. package/vendor/ramsey/uuid/src/Validator/ValidatorInterface.php +39 -0
  418. package/vendor/ramsey/uuid/src/Variant.php +60 -0
  419. package/vendor/ramsey/uuid/src/functions.php +160 -0
  420. package/vendor/ramsey/uuid/tests/BinaryUtilsTest.php +381 -0
  421. package/vendor/ramsey/uuid/tests/Builder/FallbackBuilderTest.php +198 -0
  422. package/vendor/ramsey/uuid/tests/Codec/GuidStringCodecTest.php +118 -0
  423. package/vendor/ramsey/uuid/tests/Codec/OrderedTimeCodecTest.php +258 -0
  424. package/vendor/ramsey/uuid/tests/Codec/StringCodecTest.php +149 -0
  425. package/vendor/ramsey/uuid/tests/Converter/Number/GenericNumberConverterTest.php +28 -0
  426. package/vendor/ramsey/uuid/tests/Converter/Time/GenericTimeConverterTest.php +147 -0
  427. package/vendor/ramsey/uuid/tests/Converter/Time/PhpTimeConverterTest.php +199 -0
  428. package/vendor/ramsey/uuid/tests/Converter/Time/UnixTimeConverterTest.php +202 -0
  429. package/vendor/ramsey/uuid/tests/Encoder/TimestampFirstCombCodecTest.php +105 -0
  430. package/vendor/ramsey/uuid/tests/Encoder/TimestampLastCombCodecTest.php +106 -0
  431. package/vendor/ramsey/uuid/tests/ExpectedBehaviorTest.php +573 -0
  432. package/vendor/ramsey/uuid/tests/FeatureSetTest.php +88 -0
  433. package/vendor/ramsey/uuid/tests/FunctionsTest.php +151 -0
  434. package/vendor/ramsey/uuid/tests/Generator/CombGeneratorTest.php +134 -0
  435. package/vendor/ramsey/uuid/tests/Generator/DceSecurityGeneratorTest.php +282 -0
  436. package/vendor/ramsey/uuid/tests/Generator/DefaultNameGeneratorTest.php +83 -0
  437. package/vendor/ramsey/uuid/tests/Generator/DefaultTimeGeneratorTest.php +202 -0
  438. package/vendor/ramsey/uuid/tests/Generator/NameGeneratorFactoryTest.php +19 -0
  439. package/vendor/ramsey/uuid/tests/Generator/PeclUuidNameGeneratorTest.php +107 -0
  440. package/vendor/ramsey/uuid/tests/Generator/PeclUuidRandomGeneratorTest.php +30 -0
  441. package/vendor/ramsey/uuid/tests/Generator/PeclUuidTimeGeneratorTest.php +30 -0
  442. package/vendor/ramsey/uuid/tests/Generator/RandomBytesGeneratorTest.php +70 -0
  443. package/vendor/ramsey/uuid/tests/Generator/RandomGeneratorFactoryTest.php +19 -0
  444. package/vendor/ramsey/uuid/tests/Generator/TimeGeneratorFactoryTest.php +33 -0
  445. package/vendor/ramsey/uuid/tests/Generator/UnixTimeGeneratorTest.php +204 -0
  446. package/vendor/ramsey/uuid/tests/Guid/FieldsTest.php +235 -0
  447. package/vendor/ramsey/uuid/tests/Guid/GuidBuilderTest.php +33 -0
  448. package/vendor/ramsey/uuid/tests/Math/BrickMathCalculatorTest.php +116 -0
  449. package/vendor/ramsey/uuid/tests/Nonstandard/FieldsTest.php +84 -0
  450. package/vendor/ramsey/uuid/tests/Nonstandard/UuidBuilderTest.php +33 -0
  451. package/vendor/ramsey/uuid/tests/Nonstandard/UuidV6Test.php +192 -0
  452. package/vendor/ramsey/uuid/tests/Provider/Dce/SystemDceSecurityProviderTest.php +505 -0
  453. package/vendor/ramsey/uuid/tests/Provider/Node/FallbackNodeProviderTest.php +87 -0
  454. package/vendor/ramsey/uuid/tests/Provider/Node/RandomNodeProviderTest.php +124 -0
  455. package/vendor/ramsey/uuid/tests/Provider/Node/StaticNodeProviderTest.php +58 -0
  456. package/vendor/ramsey/uuid/tests/Provider/Node/SystemNodeProviderTest.php +950 -0
  457. package/vendor/ramsey/uuid/tests/Provider/Time/FixedTimeProviderTest.php +41 -0
  458. package/vendor/ramsey/uuid/tests/Provider/Time/SystemTimeProviderTest.php +20 -0
  459. package/vendor/ramsey/uuid/tests/Rfc4122/FieldsTest.php +260 -0
  460. package/vendor/ramsey/uuid/tests/Rfc4122/UuidBuilderTest.php +145 -0
  461. package/vendor/ramsey/uuid/tests/Rfc4122/UuidV1Test.php +123 -0
  462. package/vendor/ramsey/uuid/tests/Rfc4122/UuidV2Test.php +214 -0
  463. package/vendor/ramsey/uuid/tests/Rfc4122/UuidV3Test.php +56 -0
  464. package/vendor/ramsey/uuid/tests/Rfc4122/UuidV4Test.php +56 -0
  465. package/vendor/ramsey/uuid/tests/Rfc4122/UuidV5Test.php +56 -0
  466. package/vendor/ramsey/uuid/tests/Rfc4122/UuidV6Test.php +221 -0
  467. package/vendor/ramsey/uuid/tests/Rfc4122/UuidV7Test.php +131 -0
  468. package/vendor/ramsey/uuid/tests/Rfc4122/UuidV8Test.php +56 -0
  469. package/vendor/ramsey/uuid/tests/Rfc4122/ValidatorTest.php +122 -0
  470. package/vendor/ramsey/uuid/tests/Rfc4122/VariantTraitTest.php +109 -0
  471. package/vendor/ramsey/uuid/tests/TestCase.php +29 -0
  472. package/vendor/ramsey/uuid/tests/Type/DecimalTest.php +305 -0
  473. package/vendor/ramsey/uuid/tests/Type/HexadecimalTest.php +112 -0
  474. package/vendor/ramsey/uuid/tests/Type/IntegerTest.php +235 -0
  475. package/vendor/ramsey/uuid/tests/Type/TimeTest.php +120 -0
  476. package/vendor/ramsey/uuid/tests/UuidFactoryTest.php +233 -0
  477. package/vendor/ramsey/uuid/tests/UuidTest.php +1910 -0
  478. package/vendor/ramsey/uuid/tests/Validator/GenericValidatorTest.php +98 -0
  479. package/vendor/ramsey/uuid/tests/benchmark/GuidConversionBench.php +43 -0
  480. package/vendor/ramsey/uuid/tests/benchmark/NonLazyUuidConversionBench.php +39 -0
  481. package/vendor/ramsey/uuid/tests/benchmark/UuidFieldExtractionBench.php +86 -0
  482. package/vendor/ramsey/uuid/tests/benchmark/UuidGenerationBench.php +113 -0
  483. package/vendor/ramsey/uuid/tests/benchmark/UuidSerializationBench.php +206 -0
  484. package/vendor/ramsey/uuid/tests/benchmark/UuidStringConversionBench.php +257 -0
  485. package/vendor/ramsey/uuid/tests/bootstrap.php +12 -0
  486. package/vendor/ramsey/uuid/tests/static-analysis/UuidIsImmutable.php +96 -0
  487. package/vendor/ramsey/uuid/tests/static-analysis/UuidIsNeverEmpty.php +36 -0
  488. package/vendor/ramsey/uuid/tests/static-analysis/ValidUuidIsNonEmpty.php +44 -0
  489. package/vendor/ramsey/uuid/tests/static-analysis/stubs.php +33 -0
  490. package/vendor/symfony/polyfill-ctype/Ctype.php +232 -0
  491. package/vendor/symfony/polyfill-ctype/LICENSE +19 -0
  492. package/vendor/symfony/polyfill-ctype/README.md +12 -0
  493. package/vendor/symfony/polyfill-ctype/bootstrap.php +50 -0
  494. package/vendor/symfony/polyfill-ctype/bootstrap80.php +46 -0
  495. package/vendor/symfony/polyfill-ctype/composer.json +41 -0
  496. package/vendor/symfony/polyfill-mbstring/LICENSE +19 -0
  497. package/vendor/symfony/polyfill-mbstring/Mbstring.php +947 -0
  498. package/vendor/symfony/polyfill-mbstring/README.md +13 -0
  499. package/vendor/symfony/polyfill-mbstring/Resources/unidata/caseFolding.php +119 -0
  500. package/vendor/symfony/polyfill-mbstring/Resources/unidata/lowerCase.php +1397 -0
  501. package/vendor/symfony/polyfill-mbstring/Resources/unidata/titleCaseRegexp.php +5 -0
  502. package/vendor/symfony/polyfill-mbstring/Resources/unidata/upperCase.php +1489 -0
  503. package/vendor/symfony/polyfill-mbstring/bootstrap.php +151 -0
  504. package/vendor/symfony/polyfill-mbstring/bootstrap80.php +147 -0
  505. package/vendor/symfony/polyfill-mbstring/composer.json +41 -0
  506. package/vendor/symfony/polyfill-php80/LICENSE +19 -0
  507. package/vendor/symfony/polyfill-php80/Php80.php +115 -0
  508. package/vendor/symfony/polyfill-php80/PhpToken.php +103 -0
  509. package/vendor/symfony/polyfill-php80/README.md +25 -0
  510. package/vendor/symfony/polyfill-php80/Resources/stubs/Attribute.php +31 -0
  511. package/vendor/symfony/polyfill-php80/Resources/stubs/PhpToken.php +16 -0
  512. package/vendor/symfony/polyfill-php80/Resources/stubs/Stringable.php +20 -0
  513. package/vendor/symfony/polyfill-php80/Resources/stubs/UnhandledMatchError.php +16 -0
  514. package/vendor/symfony/polyfill-php80/Resources/stubs/ValueError.php +16 -0
  515. package/vendor/symfony/polyfill-php80/bootstrap.php +42 -0
  516. package/vendor/symfony/polyfill-php80/composer.json +40 -0
  517. package/vendor/vlucas/phpdotenv/.editorconfig +15 -0
  518. package/vendor/vlucas/phpdotenv/.gitattributes +17 -0
  519. package/vendor/vlucas/phpdotenv/.github/CODE_OF_CONDUCT.md +132 -0
  520. package/vendor/vlucas/phpdotenv/.github/CONTRIBUTING.md +30 -0
  521. package/vendor/vlucas/phpdotenv/.github/FUNDING.yml +2 -0
  522. package/vendor/vlucas/phpdotenv/.github/SECURITY.md +14 -0
  523. package/vendor/vlucas/phpdotenv/.github/workflows/static.yml +74 -0
  524. package/vendor/vlucas/phpdotenv/.github/workflows/tests.yml +70 -0
  525. package/vendor/vlucas/phpdotenv/LICENSE +30 -0
  526. package/vendor/vlucas/phpdotenv/Makefile +26 -0
  527. package/vendor/vlucas/phpdotenv/README.md +363 -0
  528. package/vendor/vlucas/phpdotenv/UPGRADING.md +196 -0
  529. package/vendor/vlucas/phpdotenv/composer.json +60 -0
  530. package/vendor/vlucas/phpdotenv/phpstan-baseline.neon +21 -0
  531. package/vendor/vlucas/phpdotenv/phpstan.neon.dist +7 -0
  532. package/vendor/vlucas/phpdotenv/phpunit.xml.dist +13 -0
  533. package/vendor/vlucas/phpdotenv/psalm-baseline.xml +28 -0
  534. package/vendor/vlucas/phpdotenv/psalm.xml +13 -0
  535. package/vendor/vlucas/phpdotenv/src/Dotenv.php +267 -0
  536. package/vendor/vlucas/phpdotenv/src/Exception/ExceptionInterface.php +12 -0
  537. package/vendor/vlucas/phpdotenv/src/Exception/InvalidEncodingException.php +12 -0
  538. package/vendor/vlucas/phpdotenv/src/Exception/InvalidFileException.php +12 -0
  539. package/vendor/vlucas/phpdotenv/src/Exception/InvalidPathException.php +12 -0
  540. package/vendor/vlucas/phpdotenv/src/Exception/ValidationException.php +12 -0
  541. package/vendor/vlucas/phpdotenv/src/Loader/Loader.php +47 -0
  542. package/vendor/vlucas/phpdotenv/src/Loader/LoaderInterface.php +20 -0
  543. package/vendor/vlucas/phpdotenv/src/Loader/Resolver.php +65 -0
  544. package/vendor/vlucas/phpdotenv/src/Parser/Entry.php +59 -0
  545. package/vendor/vlucas/phpdotenv/src/Parser/EntryParser.php +300 -0
  546. package/vendor/vlucas/phpdotenv/src/Parser/Lexer.php +58 -0
  547. package/vendor/vlucas/phpdotenv/src/Parser/Lines.php +127 -0
  548. package/vendor/vlucas/phpdotenv/src/Parser/Parser.php +53 -0
  549. package/vendor/vlucas/phpdotenv/src/Parser/ParserInterface.php +19 -0
  550. package/vendor/vlucas/phpdotenv/src/Parser/Value.php +88 -0
  551. package/vendor/vlucas/phpdotenv/src/Repository/Adapter/AdapterInterface.php +15 -0
  552. package/vendor/vlucas/phpdotenv/src/Repository/Adapter/ApacheAdapter.php +89 -0
  553. package/vendor/vlucas/phpdotenv/src/Repository/Adapter/ArrayAdapter.php +80 -0
  554. package/vendor/vlucas/phpdotenv/src/Repository/Adapter/EnvConstAdapter.php +89 -0
  555. package/vendor/vlucas/phpdotenv/src/Repository/Adapter/GuardedWriter.php +85 -0
  556. package/vendor/vlucas/phpdotenv/src/Repository/Adapter/ImmutableWriter.php +110 -0
  557. package/vendor/vlucas/phpdotenv/src/Repository/Adapter/MultiReader.php +48 -0
  558. package/vendor/vlucas/phpdotenv/src/Repository/Adapter/MultiWriter.php +64 -0
  559. package/vendor/vlucas/phpdotenv/src/Repository/Adapter/PutenvAdapter.php +91 -0
  560. package/vendor/vlucas/phpdotenv/src/Repository/Adapter/ReaderInterface.php +17 -0
  561. package/vendor/vlucas/phpdotenv/src/Repository/Adapter/ReplacingWriter.php +104 -0
  562. package/vendor/vlucas/phpdotenv/src/Repository/Adapter/ServerConstAdapter.php +89 -0
  563. package/vendor/vlucas/phpdotenv/src/Repository/Adapter/WriterInterface.php +27 -0
  564. package/vendor/vlucas/phpdotenv/src/Repository/AdapterRepository.php +107 -0
  565. package/vendor/vlucas/phpdotenv/src/Repository/RepositoryBuilder.php +272 -0
  566. package/vendor/vlucas/phpdotenv/src/Repository/RepositoryInterface.php +51 -0
  567. package/vendor/vlucas/phpdotenv/src/Store/File/Paths.php +44 -0
  568. package/vendor/vlucas/phpdotenv/src/Store/File/Reader.php +81 -0
  569. package/vendor/vlucas/phpdotenv/src/Store/FileStore.php +72 -0
  570. package/vendor/vlucas/phpdotenv/src/Store/StoreBuilder.php +141 -0
  571. package/vendor/vlucas/phpdotenv/src/Store/StoreInterface.php +17 -0
  572. package/vendor/vlucas/phpdotenv/src/Store/StringStore.php +37 -0
  573. package/vendor/vlucas/phpdotenv/src/Util/Regex.php +112 -0
  574. package/vendor/vlucas/phpdotenv/src/Util/Str.php +98 -0
  575. package/vendor/vlucas/phpdotenv/src/Validator.php +209 -0
  576. package/vendor/vlucas/phpdotenv/tests/Dotenv/DotenvTest.php +387 -0
  577. package/vendor/vlucas/phpdotenv/tests/Dotenv/Loader/LoaderTest.php +86 -0
  578. package/vendor/vlucas/phpdotenv/tests/Dotenv/Parser/EntryParserTest.php +234 -0
  579. package/vendor/vlucas/phpdotenv/tests/Dotenv/Parser/LexerTest.php +40 -0
  580. package/vendor/vlucas/phpdotenv/tests/Dotenv/Parser/LinesTest.php +53 -0
  581. package/vendor/vlucas/phpdotenv/tests/Dotenv/Parser/ParserTest.php +98 -0
  582. package/vendor/vlucas/phpdotenv/tests/Dotenv/Repository/Adapter/ArrayAdapterTest.php +57 -0
  583. package/vendor/vlucas/phpdotenv/tests/Dotenv/Repository/Adapter/EnvConstAdapterTest.php +75 -0
  584. package/vendor/vlucas/phpdotenv/tests/Dotenv/Repository/Adapter/PutenvAdapterTest.php +52 -0
  585. package/vendor/vlucas/phpdotenv/tests/Dotenv/Repository/Adapter/ServerConstAdapterTest.php +75 -0
  586. package/vendor/vlucas/phpdotenv/tests/Dotenv/Repository/RepositoryTest.php +305 -0
  587. package/vendor/vlucas/phpdotenv/tests/Dotenv/Store/StoreTest.php +141 -0
  588. package/vendor/vlucas/phpdotenv/tests/Dotenv/ValidatorTest.php +479 -0
  589. package/vendor/vlucas/phpdotenv/tests/fixtures/env/.env +5 -0
  590. package/vendor/vlucas/phpdotenv/tests/fixtures/env/assertions.env +18 -0
  591. package/vendor/vlucas/phpdotenv/tests/fixtures/env/booleans.env +33 -0
  592. package/vendor/vlucas/phpdotenv/tests/fixtures/env/commented.env +15 -0
  593. package/vendor/vlucas/phpdotenv/tests/fixtures/env/empty.env +1 -0
  594. package/vendor/vlucas/phpdotenv/tests/fixtures/env/example.env +1 -0
  595. package/vendor/vlucas/phpdotenv/tests/fixtures/env/exported.env +7 -0
  596. package/vendor/vlucas/phpdotenv/tests/fixtures/env/immutable.env +1 -0
  597. package/vendor/vlucas/phpdotenv/tests/fixtures/env/integers.env +17 -0
  598. package/vendor/vlucas/phpdotenv/tests/fixtures/env/large.env +2 -0
  599. package/vendor/vlucas/phpdotenv/tests/fixtures/env/multibyte.env +3 -0
  600. package/vendor/vlucas/phpdotenv/tests/fixtures/env/multiline.env +14 -0
  601. package/vendor/vlucas/phpdotenv/tests/fixtures/env/multiple.env +4 -0
  602. package/vendor/vlucas/phpdotenv/tests/fixtures/env/mutable.env +1 -0
  603. package/vendor/vlucas/phpdotenv/tests/fixtures/env/nested.env +15 -0
  604. package/vendor/vlucas/phpdotenv/tests/fixtures/env/quoted.env +11 -0
  605. package/vendor/vlucas/phpdotenv/tests/fixtures/env/specialchars.env +8 -0
  606. package/vendor/vlucas/phpdotenv/tests/fixtures/env/unicodevarnames.env +2 -0
  607. package/vendor/vlucas/phpdotenv/tests/fixtures/env/utf8-with-bom-encoding.env +3 -0
  608. package/vendor/vlucas/phpdotenv/tests/fixtures/env/windows.env +1 -0
  609. package/vendor/vlucas/phpdotenv/vendor-bin/phpstan/composer.json +16 -0
  610. package/vendor/vlucas/phpdotenv/vendor-bin/psalm/composer.json +9 -0
@@ -0,0 +1,2596 @@
1
+ <?php
2
+
3
+ declare(strict_types=1);
4
+
5
+ namespace Brick\Math\Tests;
6
+
7
+ use Brick\Math\BigDecimal;
8
+ use Brick\Math\Exception\DivisionByZeroException;
9
+ use Brick\Math\Exception\MathException;
10
+ use Brick\Math\Exception\NegativeNumberException;
11
+ use Brick\Math\Exception\NumberFormatException;
12
+ use Brick\Math\Exception\RoundingNecessaryException;
13
+ use Brick\Math\RoundingMode;
14
+
15
+ /**
16
+ * Unit tests for class BigDecimal.
17
+ */
18
+ class BigDecimalTest extends AbstractTestCase
19
+ {
20
+ /**
21
+ * @dataProvider providerOf
22
+ *
23
+ * @param string|number $value The value to convert to a BigDecimal.
24
+ * @param string $unscaledValue The expected unscaled value.
25
+ * @param int $scale The expected scale.
26
+ */
27
+ public function testOf($value, string $unscaledValue, int $scale) : void
28
+ {
29
+ self::assertBigDecimalInternalValues($unscaledValue, $scale, BigDecimal::of($value));
30
+ }
31
+
32
+ public function providerOf() : array
33
+ {
34
+ return [
35
+ [0, '0', 0],
36
+ [1, '1', 0],
37
+ [-1, '-1', 0],
38
+ [123456789, '123456789', 0],
39
+ [-123456789, '-123456789', 0],
40
+ [PHP_INT_MAX, (string) PHP_INT_MAX, 0],
41
+ [PHP_INT_MIN, (string) PHP_INT_MIN, 0],
42
+
43
+ [0.0, '0', 0],
44
+ [0.1, '1', 1],
45
+ [1.0, '1', 0],
46
+ [1.1, '11', 1],
47
+
48
+ ['0', '0', 0],
49
+ ['+0', '0', 0],
50
+ ['-0', '0', 0],
51
+ ['00', '0', 0],
52
+ ['+00', '0', 0],
53
+ ['-00', '0', 0],
54
+
55
+ ['1', '1', 0],
56
+ ['+1', '1', 0],
57
+ ['-1', '-1', 0],
58
+ ['01', '1', 0],
59
+ ['+01', '1', 0],
60
+ ['-01', '-1', 0],
61
+
62
+ ['0.0', '0', 1],
63
+ ['+0.0', '0', 1],
64
+ ['-0.0', '0', 1],
65
+ ['00.0', '0', 1],
66
+ ['+00.0', '0', 1],
67
+ ['-00.0', '0', 1],
68
+
69
+ ['.0', '0', 1],
70
+ ['.00', '0', 2],
71
+ ['.123', '123', 3],
72
+ ['+.2', '2', 1],
73
+ ['-.33', '-33', 2],
74
+ ['1.e2', '100', 0],
75
+ ['.1e-1', '1', 2],
76
+ ['.1e0', '1', 1],
77
+ ['.1e1', '1', 0],
78
+ ['.1e2', '10', 0],
79
+ ['1.e-2', '1', 2],
80
+ ['.1e-2', '1', 3],
81
+ ['.12e1', '12', 1],
82
+ ['.012e1', '12', 2],
83
+ ['-.15e3', '-150', 0],
84
+
85
+ ['1.', '1', 0],
86
+ ['+12.', '12', 0],
87
+ ['-123.', '-123', 0],
88
+
89
+ ['1.0', '10', 1],
90
+ ['+1.0', '10', 1],
91
+ ['-1.0', '-10', 1],
92
+ ['01.0', '10', 1],
93
+ ['+01.0', '10', 1],
94
+ ['-01.0', '-10', 1],
95
+
96
+ ['0.1', '1', 1],
97
+ ['+0.1', '1', 1],
98
+ ['-0.1', '-1', 1],
99
+ ['0.10', '10', 2],
100
+ ['+0.10', '10', 2],
101
+ ['-0.10', '-10', 2],
102
+ ['0.010', '10', 3],
103
+ ['+0.010', '10', 3],
104
+ ['-0.010', '-10', 3],
105
+
106
+ ['00.1', '1', 1],
107
+ ['+00.1', '1', 1],
108
+ ['-00.1', '-1', 1],
109
+ ['00.10', '10', 2],
110
+ ['+00.10', '10', 2],
111
+ ['-00.10', '-10', 2],
112
+ ['00.010', '10', 3],
113
+ ['+00.010', '10', 3],
114
+ ['-00.010', '-10', 3],
115
+
116
+ ['01.1', '11', 1],
117
+ ['+01.1', '11', 1],
118
+ ['-01.1', '-11', 1],
119
+ ['01.010', '1010', 3],
120
+ ['+01.010', '1010', 3],
121
+ ['-01.010', '-1010', 3],
122
+
123
+ ['0e-2', '0', 2],
124
+ ['0e-1', '0', 1],
125
+ ['0e-0', '0', 0],
126
+ ['0e0', '0', 0],
127
+ ['0e1', '0', 0],
128
+ ['0e2', '0', 0],
129
+ ['0e+0', '0', 0],
130
+ ['0e+1','0', 0],
131
+ ['0e+2','0', 0],
132
+
133
+ ['0.0e-2', '0', 3],
134
+ ['0.0e-1', '0', 2],
135
+ ['0.0e-0', '0', 1],
136
+ ['0.0e0', '0', 1],
137
+ ['0.0e1', '0', 0],
138
+ ['0.0e2', '0', 0],
139
+ ['0.0e+0', '0', 1],
140
+ ['0.0e+1','0', 0],
141
+ ['0.0e+2','0', 0],
142
+
143
+ ['0.1e-2', '1', 3],
144
+ ['0.1e-1', '1', 2],
145
+ ['0.1e-0', '1', 1],
146
+ ['0.1e0', '1', 1],
147
+ ['0.1e1', '1', 0],
148
+ ['0.1e2', '10', 0],
149
+ ['0.1e+0', '1', 1],
150
+ ['0.1e+1','1', 0],
151
+ ['0.1e+2','10', 0],
152
+ ['1.23e+011', '123000000000', 0],
153
+ ['1.23e-011', '123', 13],
154
+
155
+ ['0.01e-2', '1', 4],
156
+ ['0.01e-1', '1', 3],
157
+ ['0.01e-0', '1', 2],
158
+ ['0.01e0', '1', 2],
159
+ ['0.01e1', '1', 1],
160
+ ['0.01e2', '1', 0],
161
+ ['0.01e+0', '1', 2],
162
+ ['0.01e+1','1', 1],
163
+ ['0.01e+2','1', 0],
164
+
165
+ ['0.10e-2', '10', 4],
166
+ ['0.10e-1', '10', 3],
167
+ ['0.10e-0', '10', 2],
168
+ ['0.10e0', '10', 2],
169
+ ['0.10e1', '10', 1],
170
+ ['0.10e2', '10', 0],
171
+ ['0.10e+0', '10', 2],
172
+ ['0.10e+1','10', 1],
173
+ ['0.10e+2','10', 0],
174
+
175
+ ['00.10e-2', '10', 4],
176
+ ['+00.10e-1', '10', 3],
177
+ ['-00.10e-0', '-10', 2],
178
+ ['00.10e0', '10', 2],
179
+ ['+00.10e1', '10', 1],
180
+ ['-00.10e2', '-10', 0],
181
+ ['00.10e+0', '10', 2],
182
+ ['+00.10e+1','10', 1],
183
+ ['-00.10e+2','-10', 0],
184
+ ];
185
+ }
186
+
187
+ /**
188
+ * @dataProvider providerOfFloatInDifferentLocales
189
+ */
190
+ public function testOfFloatInDifferentLocales(string $locale) : void
191
+ {
192
+ $originalLocale = setlocale(LC_NUMERIC, '0');
193
+ $setLocale = setlocale(LC_NUMERIC, $locale);
194
+
195
+ if ($setLocale !== $locale) {
196
+ setlocale(LC_NUMERIC, $originalLocale);
197
+ self::markTestSkipped('Locale ' . $locale . ' is not supported on this system.');
198
+ }
199
+
200
+ // Test a large enough number (thousands separator) with decimal digits (decimal separator)
201
+ self::assertSame('2500.5', (string) BigDecimal::of(5001/2));
202
+
203
+ // Ensure that the locale has been reset to its original value by BigNumber::of()
204
+ self::assertSame($locale, setlocale(LC_NUMERIC, '0'));
205
+
206
+ setlocale(LC_NUMERIC, $originalLocale);
207
+ }
208
+
209
+ public function providerOfFloatInDifferentLocales() : array
210
+ {
211
+ return [
212
+ ['C'],
213
+ ['en_US.UTF-8'],
214
+ ['de_DE.UTF-8'],
215
+ ['es_ES'],
216
+ ['fr_FR'],
217
+ ['fr_FR.iso88591'],
218
+ ['fr_FR.iso885915@euro'],
219
+ ['fr_FR@euro'],
220
+ ['fr_FR.utf8'],
221
+ ['ps_AF'],
222
+ ];
223
+ }
224
+
225
+ /**
226
+ * @dataProvider providerOfInvalidValueThrowsException
227
+ */
228
+ public function testOfInvalidValueThrowsException($value) : void
229
+ {
230
+ $this->expectException(NumberFormatException::class);
231
+ BigDecimal::of($value);
232
+ }
233
+
234
+ public function providerOfInvalidValueThrowsException() : array
235
+ {
236
+ return [
237
+ [''],
238
+ ['a'],
239
+ [' 1'],
240
+ ['1 '],
241
+ ['..1'],
242
+ ['1..'],
243
+ ['.1.'],
244
+ ['+'],
245
+ ['-'],
246
+ ['.'],
247
+ ['1e'],
248
+ ['.e'],
249
+ ['.e1'],
250
+ ['1e+'],
251
+ ['1e-'],
252
+ ['+e1'],
253
+ ['-e2'],
254
+ ['.e3'],
255
+ ['+a'],
256
+ ['-a'],
257
+ ['1e1000000000000000000000000000000'],
258
+ ['1e-1000000000000000000000000000000'],
259
+ [INF],
260
+ [-INF],
261
+ [NAN],
262
+ ];
263
+ }
264
+
265
+ public function testOfBigDecimalReturnsThis() : void
266
+ {
267
+ $decimal = BigDecimal::of(123);
268
+
269
+ self::assertSame($decimal, BigDecimal::of($decimal));
270
+ }
271
+
272
+ /**
273
+ * @dataProvider providerOfUnscaledValue
274
+ *
275
+ * @param string|int $unscaledValue The unscaled value of the BigDecimal to create.
276
+ * @param int $scale The scale of the BigDecimal to create.
277
+ * @param string $expectedUnscaledValue The expected result unscaled value.
278
+ */
279
+ public function testOfUnscaledValue($unscaledValue, int $scale, string $expectedUnscaledValue) : void
280
+ {
281
+ $number = BigDecimal::ofUnscaledValue($unscaledValue, $scale);
282
+ self::assertBigDecimalInternalValues($expectedUnscaledValue, $scale, $number);
283
+ }
284
+
285
+ public function providerOfUnscaledValue() : array
286
+ {
287
+ return [
288
+ [123456789, 0, '123456789'],
289
+ [123456789, 1, '123456789'],
290
+ [-123456789, 0, '-123456789'],
291
+ [-123456789, 1, '-123456789'],
292
+
293
+ ['123456789012345678901234567890', 0, '123456789012345678901234567890'],
294
+ ['123456789012345678901234567890', 1, '123456789012345678901234567890'],
295
+ ['+123456789012345678901234567890', 0, '123456789012345678901234567890'],
296
+ ['+123456789012345678901234567890', 1, '123456789012345678901234567890'],
297
+ ['-123456789012345678901234567890', 0, '-123456789012345678901234567890'],
298
+ ['-123456789012345678901234567890', 1, '-123456789012345678901234567890'],
299
+
300
+ ['0123456789012345678901234567890', 0, '123456789012345678901234567890'],
301
+ ['0123456789012345678901234567890', 1, '123456789012345678901234567890'],
302
+ ['+0123456789012345678901234567890', 0, '123456789012345678901234567890'],
303
+ ['+0123456789012345678901234567890', 1, '123456789012345678901234567890'],
304
+ ['-0123456789012345678901234567890', 0, '-123456789012345678901234567890'],
305
+ ['-0123456789012345678901234567890', 1, '-123456789012345678901234567890'],
306
+ ];
307
+ }
308
+
309
+ public function testOfUnscaledValueWithDefaultScale() : void
310
+ {
311
+ $number = BigDecimal::ofUnscaledValue('123456789');
312
+ self::assertBigDecimalInternalValues('123456789', 0, $number);
313
+ }
314
+
315
+ public function testOfUnscaledValueWithNegativeScaleThrowsException() : void
316
+ {
317
+ $this->expectException(\InvalidArgumentException::class);
318
+ BigDecimal::ofUnscaledValue('0', -1);
319
+ }
320
+
321
+ public function testZero() : void
322
+ {
323
+ self::assertBigDecimalInternalValues('0', 0, BigDecimal::zero());
324
+ self::assertSame(BigDecimal::zero(), BigDecimal::zero());
325
+ }
326
+
327
+ public function testOne() : void
328
+ {
329
+ self::assertBigDecimalInternalValues('1', 0, BigDecimal::one());
330
+ self::assertSame(BigDecimal::one(), BigDecimal::one());
331
+ }
332
+
333
+ public function testTen() : void
334
+ {
335
+ self::assertBigDecimalInternalValues('10', 0, BigDecimal::ten());
336
+ self::assertSame(BigDecimal::ten(), BigDecimal::ten());
337
+ }
338
+
339
+ /**
340
+ * @dataProvider providerMin
341
+ *
342
+ * @param array $values The values to compare.
343
+ * @param string $min The expected minimum value.
344
+ */
345
+ public function testMin(array $values, string $min) : void
346
+ {
347
+ self::assertBigDecimalEquals($min, BigDecimal::min(... $values));
348
+ }
349
+
350
+ public function providerMin() : array
351
+ {
352
+ return [
353
+ [[0, 1, -1], '-1'],
354
+ [[0, 1, -1, -1.2], '-1.2'],
355
+ [['1e30', '123456789123456789123456789', 2e25], '20000000000000000000000000'],
356
+ [['1e30', '123456789123456789123456789', 2e26], '123456789123456789123456789'],
357
+ [[0, '10', '5989', '-3/3'], '-1'],
358
+ [['-0.0000000000000000000000000000001', '0'], '-0.0000000000000000000000000000001'],
359
+ [['0.00000000000000000000000000000001', '0'], '0'],
360
+ [['-1', '1', '2', '3', '-2973/30'], '-99.1'],
361
+ [['999999999999999999999999999.99999999999', '1000000000000000000000000000'], '999999999999999999999999999.99999999999'],
362
+ [['-999999999999999999999999999.99999999999', '-1000000000000000000000000000'], '-1000000000000000000000000000'],
363
+ [['9.9e50', '1e50'], '100000000000000000000000000000000000000000000000000'],
364
+ [['9.9e50', '1e51'], '990000000000000000000000000000000000000000000000000'],
365
+ ];
366
+ }
367
+
368
+ public function testMinOfZeroValuesThrowsException() : void
369
+ {
370
+ $this->expectException(\InvalidArgumentException::class);
371
+ BigDecimal::min();
372
+ }
373
+
374
+ public function testMinOfNonDecimalValuesThrowsException() : void
375
+ {
376
+ $this->expectException(RoundingNecessaryException::class);
377
+ BigDecimal::min(1, '1/3');
378
+ }
379
+
380
+ /**
381
+ * @dataProvider providerMax
382
+ *
383
+ * @param array $values The values to compare.
384
+ * @param string $max The expected maximum value.
385
+ */
386
+ public function testMax(array $values, string $max) : void
387
+ {
388
+ self::assertBigDecimalEquals($max, BigDecimal::max(... $values));
389
+ }
390
+
391
+ public function providerMax() : array
392
+ {
393
+ return [
394
+ [[0, 0.9, -1.00], '0.9'],
395
+ [[0, 0.01, -1, -1.2], '0.01'],
396
+ [[0, 0.01, -1, -1.2, '2e-1'], '0.2'],
397
+ [['1e-30', '123456789123456789123456789', 2e25], '123456789123456789123456789'],
398
+ [['1e-30', '123456789123456789123456789', 2e26], '200000000000000000000000000'],
399
+ [[0, '10', '5989', '-1'], '5989'],
400
+ [[0, '10', '5989', '5989.000000000000000000000000000000001', '-1'], '5989.000000000000000000000000000000001'],
401
+ [[0, '10', '5989', '5989.000000000000000000000000000000001', '-1', '5990'], '5990'],
402
+ [['-0.0000000000000000000000000000001', 0], '0'],
403
+ [['0.00000000000000000000000000000001', '0'], '0.00000000000000000000000000000001'],
404
+ [['-1', '1', '2', '3', '-99.1'], '3'],
405
+ [['-1', '1', '2', '3', '-99.1', '31/10'], '3.1'],
406
+ [['999999999999999999999999999.99999999999', '1000000000000000000000000000'], '1000000000000000000000000000'],
407
+ [['-999999999999999999999999999.99999999999', '-1000000000000000000000000000'], '-999999999999999999999999999.99999999999'],
408
+ [['9.9e50', '1e50'], '990000000000000000000000000000000000000000000000000'],
409
+ [['9.9e50', '1e51'], '1000000000000000000000000000000000000000000000000000'],
410
+ ];
411
+ }
412
+
413
+ public function testMaxOfZeroValuesThrowsException() : void
414
+ {
415
+ $this->expectException(\InvalidArgumentException::class);
416
+ BigDecimal::max();
417
+ }
418
+
419
+ public function testMaxOfNonDecimalValuesThrowsException() : void
420
+ {
421
+ $this->expectException(RoundingNecessaryException::class);
422
+ BigDecimal::min(1, '3/7');
423
+ }
424
+
425
+ /**
426
+ * @dataProvider providerSum
427
+ *
428
+ * @param array $values The values to add.
429
+ * @param string $sum The expected sum.
430
+ */
431
+ public function testSum(array $values, string $sum) : void
432
+ {
433
+ self::assertBigDecimalEquals($sum, BigDecimal::sum(... $values));
434
+ }
435
+
436
+ public function providerSum() : array
437
+ {
438
+ return [
439
+ [[0, 0.9, -1.00], '-0.1'],
440
+ [[0, 0.01, -1, -1.2], '-2.19'],
441
+ [[0, 0.01, -1, -1.2, '2e-1'], '-1.99'],
442
+ [['1e-30', '123456789123456789123456789', 2e25], '143456789123456789123456789.000000000000000000000000000001'],
443
+ [['1e-30', '123456789123456789123456789', 2e26], '323456789123456789123456789.000000000000000000000000000001'],
444
+ [[0, '10', '5989', '-1'], '5998'],
445
+ [[0, '10', '5989', '5989.000000000000000000000000000000001', '-1'], '11987.000000000000000000000000000000001'],
446
+ [[0, '10', '5989', '5989.000000000000000000000000000000001', '-1', '5990'], '17977.000000000000000000000000000000001'],
447
+ [['-0.0000000000000000000000000000001', 0], '-0.0000000000000000000000000000001'],
448
+ [['0.00000000000000000000000000000001', '0'], '0.00000000000000000000000000000001'],
449
+ [['-1', '1', '2', '3', '-99.1'], '-94.1'],
450
+ [['-1', '1', '2', '3', '-99.1', '31/10'], '-91.0'],
451
+ [['999999999999999999999999999.99999999999', '1000000000000000000000000000'], '1999999999999999999999999999.99999999999'],
452
+ [['-999999999999999999999999999.99999999999', 47, '-1000000000000000000000000000'], '-1999999999999999999999999952.99999999999'],
453
+ [['9.9e50', '1e50', '-3/2'], '1089999999999999999999999999999999999999999999999998.5'],
454
+ [['9.9e50', '-1e-51'], '989999999999999999999999999999999999999999999999999.999999999999999999999999999999999999999999999999999'],
455
+ ];
456
+ }
457
+
458
+ public function testSumOfZeroValuesThrowsException() : void
459
+ {
460
+ $this->expectException(\InvalidArgumentException::class);
461
+ BigDecimal::sum();
462
+ }
463
+
464
+ public function testSumOfNonDecimalValuesThrowsException() : void
465
+ {
466
+ $this->expectException(RoundingNecessaryException::class);
467
+ BigDecimal::min(1, '3/7');
468
+ }
469
+
470
+ /**
471
+ * @dataProvider providerPlus
472
+ *
473
+ * @param string $a The base number.
474
+ * @param string $b The number to add.
475
+ * @param string $unscaledValue The expected unscaled value.
476
+ * @param int $scale The expected scale.
477
+ */
478
+ public function testPlus(string $a, string $b, string $unscaledValue, int $scale) : void
479
+ {
480
+ self::assertBigDecimalInternalValues($unscaledValue, $scale, BigDecimal::of($a)->plus($b));
481
+ }
482
+
483
+ public function providerPlus() : array
484
+ {
485
+ return [
486
+ ['123', '999', '1122', 0],
487
+ ['123', '999.0', '11220', 1],
488
+ ['123', '999.00', '112200', 2],
489
+ ['123.0', '999', '11220', 1],
490
+ ['123.0', '999.0', '11220', 1],
491
+ ['123.0', '999.00', '112200', 2],
492
+ ['123.00', '999', '112200', 2],
493
+ ['123.00', '999.0', '112200', 2],
494
+ ['123.00', '999.00', '112200', 2],
495
+
496
+ ['0', '999', '999', 0],
497
+ ['0', '999.0', '9990', 1],
498
+ ['0', '999.00', '99900', 2],
499
+ ['0.0', '999', '9990', 1],
500
+ ['0.0', '999.0', '9990', 1],
501
+ ['0.0', '999.00', '99900', 2],
502
+ ['0.00', '999', '99900', 2],
503
+ ['0.00', '999.0', '99900', 2],
504
+ ['0.00', '999.00', '99900', 2],
505
+
506
+ ['123', '-999', '-876', 0],
507
+ ['123', '-999.0', '-8760', 1],
508
+ ['123', '-999.00', '-87600', 2],
509
+ ['123.0', '-999', '-8760', 1],
510
+ ['123.0', '-999.0', '-8760', 1],
511
+ ['123.0', '-999.00', '-87600', 2],
512
+ ['123.00', '-999', '-87600', 2],
513
+ ['123.00', '-999.0', '-87600', 2],
514
+ ['123.00', '-999.00', '-87600', 2],
515
+
516
+ ['-123', '999', '876', 0],
517
+ ['-123', '999.0', '8760', 1],
518
+ ['-123', '999.00', '87600', 2],
519
+ ['-123.0', '999', '8760', 1],
520
+ ['-123.0', '999.0', '8760', 1],
521
+ ['-123.0', '999.00', '87600', 2],
522
+ ['-123.00', '999', '87600', 2],
523
+ ['-123.00', '999.0', '87600', 2],
524
+ ['-123.00', '999.00', '87600', 2],
525
+
526
+ ['-123', '-999', '-1122', 0],
527
+ ['-123', '-999.0', '-11220', 1],
528
+ ['-123', '-999.00', '-112200', 2],
529
+ ['-123.0', '-999', '-11220', 1],
530
+ ['-123.0', '-999.0', '-11220', 1],
531
+ ['-123.0', '-999.00', '-112200', 2],
532
+ ['-123.00', '-999', '-112200', 2],
533
+ ['-123.00', '-999.0', '-112200', 2],
534
+ ['-123.00', '-999.00', '-112200', 2],
535
+
536
+ ['23487837847837428335.322387091', '309049304233535454687656.2392', '309072792071383292115991561587091', 9],
537
+ ['-234878378478328335.322387091', '309049304233535154687656.232', '309049069355156676359320909612909', 9],
538
+ ['234878378478328335.3227091', '-3090495154687656.231343344452', '231787883323640679091365755548', 12],
539
+ ['-23487837847833435.3231', '-3090495154687656.231343344452', '-26578333002521091554443344452', 12],
540
+
541
+ ['1234568798347983.2334899238921', '0', '12345687983479832334899238921', 13],
542
+ ['-0.00223287647368738736428467863784', '0.000', '-223287647368738736428467863784', 32],
543
+ ];
544
+ }
545
+
546
+ /**
547
+ * @dataProvider providerMinus
548
+ *
549
+ * @param string $a The base number.
550
+ * @param string $b The number to subtract.
551
+ * @param string $unscaledValue The expected unscaled value.
552
+ * @param int $scale The expected scale.
553
+ */
554
+ public function testMinus(string $a, string $b, string $unscaledValue, int $scale) : void
555
+ {
556
+ self::assertBigDecimalInternalValues($unscaledValue, $scale, BigDecimal::of($a)->minus($b));
557
+ }
558
+
559
+ public function providerMinus() : array
560
+ {
561
+ return [
562
+ ['123', '999', '-876', 0],
563
+ ['123', '999.0', '-8760', 1],
564
+ ['123', '999.00', '-87600', 2],
565
+ ['123.0', '999', '-8760', 1],
566
+ ['123.0', '999.0', '-8760', 1],
567
+ ['123.0', '999.00', '-87600', 2],
568
+ ['123.00', '999', '-87600', 2],
569
+ ['123.00', '999.0', '-87600', 2],
570
+ ['123.00', '999.00', '-87600', 2],
571
+ ['0', '999', '-999', 0],
572
+ ['0', '999.0', '-9990', 1],
573
+
574
+ ['123', '-999', '1122', 0],
575
+ ['123', '-999.0', '11220', 1],
576
+ ['123', '-999.00', '112200', 2],
577
+ ['123.0', '-999', '11220', 1],
578
+ ['123.0', '-999.0', '11220', 1],
579
+ ['123.0', '-999.00', '112200', 2],
580
+ ['123.00', '-999', '112200', 2],
581
+ ['123.00', '-999.0', '112200', 2],
582
+ ['123.00', '-999.00', '112200', 2],
583
+
584
+ ['-123', '999', '-1122', 0],
585
+ ['-123', '999.0', '-11220', 1],
586
+ ['-123', '999.00', '-112200', 2],
587
+ ['-123.0', '999', '-11220', 1],
588
+ ['-123.0', '999.0', '-11220', 1],
589
+ ['-123.0', '999.00', '-112200', 2],
590
+ ['-123.00', '999', '-112200', 2],
591
+ ['-123.00', '999.0', '-112200', 2],
592
+ ['-123.00', '999.00', '-112200', 2],
593
+
594
+ ['-123', '-999', '876', 0],
595
+ ['-123', '-999.0', '8760', 1],
596
+ ['-123', '-999.00', '87600', 2],
597
+ ['-123.0', '-999', '8760', 1],
598
+ ['-123.0', '-999.0', '8760', 1],
599
+ ['-123.0', '-999.00', '87600', 2],
600
+ ['-123.00', '-999', '87600', 2],
601
+ ['-123.00', '-999.0', '87600', 2],
602
+ ['-123.00', '-999.00', '87600', 2],
603
+
604
+ ['234878378477428335.3223334343487091', '309049304233536.2392', '2345693291731947990831334343487091', 16],
605
+ ['-2348783784774335.32233343434891', '309049304233536.233392', '-265783308900787155572543434891', 14],
606
+ ['2348783784774335.323232342791', '-309049304233536.556172', '2657833089007871879404342791', 12],
607
+ ['-2348783784774335.3232342791', '-309049304233536.556172', '-20397344805407987670622791', 10],
608
+
609
+ ['1234568798347983.2334899238921', '0', '12345687983479832334899238921', 13],
610
+ ['0', '1234568798347983.2334899238921', '-12345687983479832334899238921', 13],
611
+ ['-0.00223287647368738736428467863784', '0.000', '-223287647368738736428467863784', 32],
612
+ ];
613
+ }
614
+
615
+ /**
616
+ * @dataProvider providerMultipliedBy
617
+ *
618
+ * @param string $a The base number.
619
+ * @param string $b The number to multiply.
620
+ * @param string $unscaledValue The expected unscaled value.
621
+ * @param int $scale The expected scale.
622
+ */
623
+ public function testMultipliedBy(string $a, string $b, string $unscaledValue, int $scale) : void
624
+ {
625
+ self::assertBigDecimalInternalValues($unscaledValue, $scale, BigDecimal::of($a)->multipliedBy($b));
626
+ }
627
+
628
+ public function providerMultipliedBy() : array
629
+ {
630
+ return [
631
+ ['123', '999', '122877', 0],
632
+ ['123', '999.0', '1228770', 1],
633
+ ['123', '999.00', '12287700', 2],
634
+ ['123.0', '999', '1228770', 1],
635
+ ['123.0', '999.0', '12287700', 2],
636
+ ['123.0', '999.00', '122877000', 3],
637
+ ['123.00', '999', '12287700', 2],
638
+ ['123.00', '999.0', '122877000', 3],
639
+ ['123.00', '999.00', '1228770000', 4],
640
+
641
+ ['123.0', '0.1', '1230', 2],
642
+ ['123.0', '0.01', '1230', 3],
643
+ ['123.1', '0.01', '1231', 3],
644
+ ['123.1', '0.001', '1231', 4],
645
+
646
+ ['123', '-999', '-122877', 0],
647
+ ['123', '-999.0', '-1228770', 1],
648
+ ['123', '-999.00', '-12287700', 2],
649
+ ['123.0', '-999', '-1228770', 1],
650
+ ['123.0', '-999.0', '-12287700', 2],
651
+ ['123.0', '-999.00', '-122877000', 3],
652
+ ['123.00', '-999', '-12287700', 2],
653
+ ['123.00', '-999.0', '-122877000', 3],
654
+ ['123.00', '-999.00', '-1228770000', 4],
655
+
656
+ ['-123', '999', '-122877', 0],
657
+ ['-123', '999.0', '-1228770', 1],
658
+ ['-123', '999.00', '-12287700', 2],
659
+ ['-123.0', '999', '-1228770', 1],
660
+ ['-123.0', '999.0', '-12287700', 2],
661
+ ['-123.0', '999.00', '-122877000', 3],
662
+ ['-123.00', '999', '-12287700', 2],
663
+ ['-123.00', '999.0', '-122877000', 3],
664
+ ['-123.00', '999.00', '-1228770000', 4],
665
+
666
+ ['-123', '-999', '122877', 0],
667
+ ['-123', '-999.0', '1228770', 1],
668
+ ['-123', '-999.00', '12287700', 2],
669
+ ['-123.0', '-999', '1228770', 1],
670
+ ['-123.0', '-999.0', '12287700', 2],
671
+ ['-123.0', '-999.00', '122877000', 3],
672
+ ['-123.00', '-999', '12287700', 2],
673
+ ['-123.00', '-999.0', '122877000', 3],
674
+ ['-123.00', '-999.00', '1228770000', 4],
675
+
676
+ ['1', '999', '999', 0],
677
+ ['1', '999.0', '9990', 1],
678
+ ['1', '999.00', '99900', 2],
679
+ ['1.0', '999', '9990', 1],
680
+ ['1.0', '999.0', '99900', 2],
681
+ ['1.0', '999.00', '999000', 3],
682
+ ['1.00', '999', '99900', 2],
683
+ ['1.00', '999.0', '999000', 3],
684
+ ['1.00', '999.00', '9990000', 4],
685
+
686
+ ['123', '1', '123', 0],
687
+ ['123', '1.0', '1230', 1],
688
+ ['123', '1.00', '12300', 2],
689
+ ['123.0', '1', '1230', 1],
690
+ ['123.0', '1.0', '12300', 2],
691
+ ['123.0', '1.00', '123000', 3],
692
+ ['123.00', '1', '12300', 2],
693
+ ['123.00', '1.0', '123000', 3],
694
+ ['123.00', '1.00', '1230000', 4],
695
+
696
+ ['0', '999', '0', 0],
697
+ ['0', '999.0', '0', 1],
698
+ ['0', '999.00', '0', 2],
699
+ ['0.0', '999', '0', 1],
700
+ ['0.0', '999.0', '0', 2],
701
+ ['0.0', '999.00', '0', 3],
702
+ ['0.00', '999', '0', 2],
703
+ ['0.00', '999.0', '0', 3],
704
+ ['0.00', '999.00', '0', 4],
705
+
706
+ ['123', '0', '0', 0],
707
+ ['123', '0.0', '0', 1],
708
+ ['123', '0.00', '0', 2],
709
+ ['123.0', '0', '0', 1],
710
+ ['123.0', '0.0', '0', 2],
711
+ ['123.0', '0.00', '0', 3],
712
+ ['123.00', '0', '0', 2],
713
+ ['123.00', '0.0', '0', 3],
714
+ ['123.00', '0.00', '0', 4],
715
+
716
+ ['589252.156111130', '999.2563989942545241223454', '5888139876152080735720775399923986443020', 31],
717
+ ['-589252.15611130', '999.256398994254524122354', '-58881398761537794715991163083004200020', 29],
718
+ ['589252.1561113', '-99.256398994254524122354', '-584870471152079471599116308300420002', 28],
719
+ ['-58952.156111', '-9.256398994254524122357', '545684678534996098129205129273627', 27],
720
+
721
+ ['0.1235437849158495728979344999999999999', '1', '1235437849158495728979344999999999999', 37],
722
+ ['-1.324985980890283098409328999999999999', '1', '-1324985980890283098409328999999999999', 36],
723
+ ];
724
+ }
725
+
726
+ /**
727
+ * @dataProvider providerDividedBy
728
+ *
729
+ * @param string $a The base number.
730
+ * @param string $b The number to divide.
731
+ * @param int|null $scale The desired scale of the result.
732
+ * @param int $roundingMode The rounding mode.
733
+ * @param string $unscaledValue The expected unscaled value of the result.
734
+ * @param int $expectedScale The expected scale of the result.
735
+ */
736
+ public function testDividedBy(string $a, string $b, ?int $scale, int $roundingMode, string $unscaledValue, int $expectedScale) : void
737
+ {
738
+ $decimal = BigDecimal::of($a)->dividedBy($b, $scale, $roundingMode);
739
+ self::assertBigDecimalInternalValues($unscaledValue, $expectedScale, $decimal);
740
+ }
741
+
742
+ public function providerDividedBy() : array
743
+ {
744
+ return [
745
+ [ '7', '0.2', 0, RoundingMode::UNNECESSARY, '35', 0],
746
+ [ '7', '-0.2', 0, RoundingMode::UNNECESSARY, '-35', 0],
747
+ ['-7', '0.2', 0, RoundingMode::UNNECESSARY, '-35', 0],
748
+ ['-7', '-0.2', 0, RoundingMode::UNNECESSARY, '35', 0],
749
+
750
+ ['1234567890123456789', '0.01', 0, RoundingMode::UNNECESSARY, '123456789012345678900', 0],
751
+ ['1234567890123456789', '0.010', 0, RoundingMode::UNNECESSARY, '123456789012345678900', 0],
752
+
753
+ ['1324794783847839472983.343898', '1', 6, RoundingMode::UNNECESSARY, '1324794783847839472983343898', 6],
754
+ ['-32479478384783947298.3343898', '1', 7, RoundingMode::UNNECESSARY, '-324794783847839472983343898', 7],
755
+
756
+ ['1.5', '2', 2, RoundingMode::UNNECESSARY, '75', 2],
757
+ ['1.5', '3', null, RoundingMode::UNNECESSARY, '5', 1],
758
+ ['0.123456789', '0.00244140625', 10, RoundingMode::UNNECESSARY, '505679007744', 10],
759
+ ['1.234', '123.456', 50, RoundingMode::DOWN, '999546397096941420425090720580611715914981855883', 50],
760
+ ['1', '3', 10, RoundingMode::UP, '3333333334', 10],
761
+ ['0.124', '0.2', 3, RoundingMode::UNNECESSARY, '620', 3],
762
+ ['0.124', '2', 3, RoundingMode::UNNECESSARY, '62', 3],
763
+ ];
764
+ }
765
+
766
+ /**
767
+ * @dataProvider providerDividedByByZeroThrowsException
768
+ *
769
+ * @param string|number $zero
770
+ */
771
+ public function testDividedByByZeroThrowsException($zero) : void
772
+ {
773
+ $this->expectException(DivisionByZeroException::class);
774
+ BigDecimal::of(1)->dividedBy($zero, 0);
775
+ }
776
+
777
+ public function providerDividedByByZeroThrowsException() : array
778
+ {
779
+ return [
780
+ [0],
781
+ [0.0],
782
+ ['0'],
783
+ ['0.0'],
784
+ ['0.00']
785
+ ];
786
+ }
787
+
788
+ /**
789
+ * @dataProvider providerExactlyDividedBy
790
+ *
791
+ * @param string|number $number The number to divide.
792
+ * @param string|number $divisor The divisor.
793
+ * @param string $expected The expected result, or a class name if an exception is expected.
794
+ */
795
+ public function testExactlyDividedBy($number, $divisor, string $expected) : void
796
+ {
797
+ $number = BigDecimal::of($number);
798
+
799
+ if (self::isException($expected)) {
800
+ $this->expectException($expected);
801
+ }
802
+
803
+ $actual = $number->exactlyDividedBy($divisor);
804
+
805
+ if (! self::isException($expected)) {
806
+ self::assertBigDecimalEquals($expected, $actual);
807
+ }
808
+ }
809
+
810
+ public function providerExactlyDividedBy() : array
811
+ {
812
+ return [
813
+ [1, 1, '1'],
814
+ ['1.0', '1.00', '1'],
815
+ [1, 2, '0.5'],
816
+ [1, 3, RoundingNecessaryException::class],
817
+ [1, 4, '0.25'],
818
+ [1, 5, '0.2'],
819
+ [1, 6, RoundingNecessaryException::class],
820
+ [1, 7, RoundingNecessaryException::class],
821
+ [1, 8, '0.125'],
822
+ [1, 9, RoundingNecessaryException::class],
823
+ [1, 10, '0.1'],
824
+ ['1.0', 2, '0.5'],
825
+ ['1.00', 2, '0.5'],
826
+ ['1.0000', 8, '0.125'],
827
+ [1, '4.000', '0.25'],
828
+ ['1', '0.125', '8'],
829
+ ['1.0', '0.125', '8'],
830
+ ['1234.5678', '2', '617.2839'],
831
+ ['1234.5678', '4', '308.64195'],
832
+ ['1234.5678', '8', '154.320975'],
833
+ ['1234.5678', '6.4', '192.90121875'],
834
+ ['7', '3125', '0.00224'],
835
+ ['4849709849456546549849846510128399', '18014398509481984', '269212976880902984.935786476657271160117801400701864622533321380615234375'],
836
+ ['4849709849456546549849846510128399', '-18014398509481984', '-269212976880902984.935786476657271160117801400701864622533321380615234375'],
837
+ ['-4849709849456546549849846510128399', '18014398509481984', '-269212976880902984.935786476657271160117801400701864622533321380615234375'],
838
+ ['-4849709849456546549849846510128399', '-18014398509481984', '269212976880902984.935786476657271160117801400701864622533321380615234375'],
839
+ ['123', '0', DivisionByZeroException::class],
840
+ [-789, '0.0', DivisionByZeroException::class],
841
+ ];
842
+ }
843
+
844
+ public function testExactlyDividedByZero() : void
845
+ {
846
+ $this->expectException(DivisionByZeroException::class);
847
+ BigDecimal::of(1)->exactlyDividedBy(0);
848
+ }
849
+
850
+ /**
851
+ * @dataProvider providerDividedByWithRoundingNecessaryThrowsException
852
+ *
853
+ * @param string $a The base number.
854
+ * @param string $b The number to divide by.
855
+ * @param int $scale The desired scale.
856
+ */
857
+ public function testDividedByWithRoundingNecessaryThrowsException(string $a, string $b, int $scale) : void
858
+ {
859
+ $this->expectException(RoundingNecessaryException::class);
860
+ BigDecimal::of($a)->dividedBy($b, $scale);
861
+ }
862
+
863
+ public function providerDividedByWithRoundingNecessaryThrowsException() : array
864
+ {
865
+ return [
866
+ ['1.234', '123.456', 3],
867
+ ['7', '2', 0],
868
+ ['7', '3', 100],
869
+ ];
870
+ }
871
+
872
+ public function testDividedByWithNegativeScaleThrowsException() : void
873
+ {
874
+ $this->expectException(\InvalidArgumentException::class);
875
+ BigDecimal::of(1)->dividedBy(2, -1);
876
+ }
877
+
878
+ public function testDividedByWithInvalidRoundingModeThrowsException() : void
879
+ {
880
+ $this->expectException(\InvalidArgumentException::class);
881
+ BigDecimal::of(1)->dividedBy(2, 0, -1);
882
+ }
883
+
884
+ /**
885
+ * @dataProvider providerRoundingMode
886
+ *
887
+ * @param int $roundingMode The rounding mode.
888
+ * @param string $number The number to round.
889
+ * @param string|null $two The expected rounding to a scale of two, or null if an exception is expected.
890
+ * @param string|null $one The expected rounding to a scale of one, or null if an exception is expected.
891
+ * @param string|null $zero The expected rounding to a scale of zero, or null if an exception is expected.
892
+ */
893
+ public function testRoundingMode(int $roundingMode, string $number, ?string $two, ?string $one, ?string $zero) : void
894
+ {
895
+ $number = BigDecimal::of($number);
896
+
897
+ $this->doTestRoundingMode($roundingMode, $number, '1', $two, $one, $zero);
898
+ $this->doTestRoundingMode($roundingMode, $number->negated(), '-1', $two, $one, $zero);
899
+ }
900
+
901
+ /**
902
+ * @param int $roundingMode The rounding mode.
903
+ * @param BigDecimal $number The number to round.
904
+ * @param string $divisor The divisor.
905
+ * @param string|null $two The expected rounding to a scale of two, or null if an exception is expected.
906
+ * @param string|null $one The expected rounding to a scale of one, or null if an exception is expected.
907
+ * @param string|null $zero The expected rounding to a scale of zero, or null if an exception is expected.
908
+ */
909
+ private function doTestRoundingMode(int $roundingMode, BigDecimal $number, string $divisor, ?string $two, ?string $one, ?string $zero) : void
910
+ {
911
+ foreach ([$zero, $one, $two] as $scale => $expected) {
912
+ if ($expected === null) {
913
+ $this->expectException(RoundingNecessaryException::class);
914
+ }
915
+
916
+ $actual = $number->dividedBy($divisor, $scale, $roundingMode);
917
+
918
+ if ($expected !== null) {
919
+ self::assertBigDecimalInternalValues($expected, $scale, $actual);
920
+ }
921
+ }
922
+ }
923
+
924
+ public function providerRoundingMode() : array
925
+ {
926
+ return [
927
+ [RoundingMode::UP, '3.501', '351', '36', '4'],
928
+ [RoundingMode::UP, '3.500', '350', '35', '4'],
929
+ [RoundingMode::UP, '3.499', '350', '35', '4'],
930
+ [RoundingMode::UP, '3.001', '301', '31', '4'],
931
+ [RoundingMode::UP, '3.000', '300', '30', '3'],
932
+ [RoundingMode::UP, '2.999', '300', '30', '3'],
933
+ [RoundingMode::UP, '2.501', '251', '26', '3'],
934
+ [RoundingMode::UP, '2.500', '250', '25', '3'],
935
+ [RoundingMode::UP, '2.499', '250', '25', '3'],
936
+ [RoundingMode::UP, '2.001', '201', '21', '3'],
937
+ [RoundingMode::UP, '2.000', '200', '20', '2'],
938
+ [RoundingMode::UP, '1.999', '200', '20', '2'],
939
+ [RoundingMode::UP, '1.501', '151', '16', '2'],
940
+ [RoundingMode::UP, '1.500', '150', '15', '2'],
941
+ [RoundingMode::UP, '1.499', '150', '15', '2'],
942
+ [RoundingMode::UP, '1.001', '101', '11', '2'],
943
+ [RoundingMode::UP, '1.000', '100', '10', '1'],
944
+ [RoundingMode::UP, '0.999', '100', '10', '1'],
945
+ [RoundingMode::UP, '0.501', '51', '6', '1'],
946
+ [RoundingMode::UP, '0.500', '50', '5', '1'],
947
+ [RoundingMode::UP, '0.499', '50', '5', '1'],
948
+ [RoundingMode::UP, '0.001', '1', '1', '1'],
949
+ [RoundingMode::UP, '0.000', '0', '0', '0'],
950
+ [RoundingMode::UP, '-0.001', '-1', '-1', '-1'],
951
+ [RoundingMode::UP, '-0.499', '-50', '-5', '-1'],
952
+ [RoundingMode::UP, '-0.500', '-50', '-5', '-1'],
953
+ [RoundingMode::UP, '-0.501', '-51', '-6', '-1'],
954
+ [RoundingMode::UP, '-0.999', '-100', '-10', '-1'],
955
+ [RoundingMode::UP, '-1.000', '-100', '-10', '-1'],
956
+ [RoundingMode::UP, '-1.001', '-101', '-11', '-2'],
957
+ [RoundingMode::UP, '-1.499', '-150', '-15', '-2'],
958
+ [RoundingMode::UP, '-1.500', '-150', '-15', '-2'],
959
+ [RoundingMode::UP, '-1.501', '-151', '-16', '-2'],
960
+ [RoundingMode::UP, '-1.999', '-200', '-20', '-2'],
961
+ [RoundingMode::UP, '-2.000', '-200', '-20', '-2'],
962
+ [RoundingMode::UP, '-2.001', '-201', '-21', '-3'],
963
+ [RoundingMode::UP, '-2.499', '-250', '-25', '-3'],
964
+ [RoundingMode::UP, '-2.500', '-250', '-25', '-3'],
965
+ [RoundingMode::UP, '-2.501', '-251', '-26', '-3'],
966
+ [RoundingMode::UP, '-2.999', '-300', '-30', '-3'],
967
+ [RoundingMode::UP, '-3.000', '-300', '-30', '-3'],
968
+ [RoundingMode::UP, '-3.001', '-301', '-31', '-4'],
969
+ [RoundingMode::UP, '-3.499', '-350', '-35', '-4'],
970
+ [RoundingMode::UP, '-3.500', '-350', '-35', '-4'],
971
+ [RoundingMode::UP, '-3.501', '-351', '-36', '-4'],
972
+
973
+ [RoundingMode::DOWN, '3.501', '350', '35', '3'],
974
+ [RoundingMode::DOWN, '3.500', '350', '35', '3'],
975
+ [RoundingMode::DOWN, '3.499', '349', '34', '3'],
976
+ [RoundingMode::DOWN, '3.001', '300', '30', '3'],
977
+ [RoundingMode::DOWN, '3.000', '300', '30', '3'],
978
+ [RoundingMode::DOWN, '2.999', '299', '29', '2'],
979
+ [RoundingMode::DOWN, '2.501', '250', '25', '2'],
980
+ [RoundingMode::DOWN, '2.500', '250', '25', '2'],
981
+ [RoundingMode::DOWN, '2.499', '249', '24', '2'],
982
+ [RoundingMode::DOWN, '2.001', '200', '20', '2'],
983
+ [RoundingMode::DOWN, '2.000', '200', '20', '2'],
984
+ [RoundingMode::DOWN, '1.999', '199', '19', '1'],
985
+ [RoundingMode::DOWN, '1.501', '150', '15', '1'],
986
+ [RoundingMode::DOWN, '1.500', '150', '15', '1'],
987
+ [RoundingMode::DOWN, '1.499', '149', '14', '1'],
988
+ [RoundingMode::DOWN, '1.001', '100', '10', '1'],
989
+ [RoundingMode::DOWN, '1.000', '100', '10', '1'],
990
+ [RoundingMode::DOWN, '0.999', '99', '9', '0'],
991
+ [RoundingMode::DOWN, '0.501', '50', '5', '0'],
992
+ [RoundingMode::DOWN, '0.500', '50', '5', '0'],
993
+ [RoundingMode::DOWN, '0.499', '49', '4', '0'],
994
+ [RoundingMode::DOWN, '0.001', '0', '0', '0'],
995
+ [RoundingMode::DOWN, '0.000', '0', '0', '0'],
996
+ [RoundingMode::DOWN, '-0.001', '0', '0', '0'],
997
+ [RoundingMode::DOWN, '-0.499', '-49', '-4', '0'],
998
+ [RoundingMode::DOWN, '-0.500', '-50', '-5', '0'],
999
+ [RoundingMode::DOWN, '-0.501', '-50', '-5', '0'],
1000
+ [RoundingMode::DOWN, '-0.999', '-99', '-9', '0'],
1001
+ [RoundingMode::DOWN, '-1.000', '-100', '-10', '-1'],
1002
+ [RoundingMode::DOWN, '-1.001', '-100', '-10', '-1'],
1003
+ [RoundingMode::DOWN, '-1.499', '-149', '-14', '-1'],
1004
+ [RoundingMode::DOWN, '-1.500', '-150', '-15', '-1'],
1005
+ [RoundingMode::DOWN, '-1.501', '-150', '-15', '-1'],
1006
+ [RoundingMode::DOWN, '-1.999', '-199', '-19', '-1'],
1007
+ [RoundingMode::DOWN, '-2.000', '-200', '-20', '-2'],
1008
+ [RoundingMode::DOWN, '-2.001', '-200', '-20', '-2'],
1009
+ [RoundingMode::DOWN, '-2.499', '-249', '-24', '-2'],
1010
+ [RoundingMode::DOWN, '-2.500', '-250', '-25', '-2'],
1011
+ [RoundingMode::DOWN, '-2.501', '-250', '-25', '-2'],
1012
+ [RoundingMode::DOWN, '-2.999', '-299', '-29', '-2'],
1013
+ [RoundingMode::DOWN, '-3.000', '-300', '-30', '-3'],
1014
+ [RoundingMode::DOWN, '-3.001', '-300', '-30', '-3'],
1015
+ [RoundingMode::DOWN, '-3.499', '-349', '-34', '-3'],
1016
+ [RoundingMode::DOWN, '-3.500', '-350', '-35', '-3'],
1017
+ [RoundingMode::DOWN, '-3.501', '-350', '-35', '-3'],
1018
+
1019
+ [RoundingMode::CEILING, '3.501', '351', '36', '4'],
1020
+ [RoundingMode::CEILING, '3.500', '350', '35', '4'],
1021
+ [RoundingMode::CEILING, '3.499', '350', '35', '4'],
1022
+ [RoundingMode::CEILING, '3.001', '301', '31', '4'],
1023
+ [RoundingMode::CEILING, '3.000', '300', '30', '3'],
1024
+ [RoundingMode::CEILING, '2.999', '300', '30', '3'],
1025
+ [RoundingMode::CEILING, '2.501', '251', '26', '3'],
1026
+ [RoundingMode::CEILING, '2.500', '250', '25', '3'],
1027
+ [RoundingMode::CEILING, '2.499', '250', '25', '3'],
1028
+ [RoundingMode::CEILING, '2.001', '201', '21', '3'],
1029
+ [RoundingMode::CEILING, '2.000', '200', '20', '2'],
1030
+ [RoundingMode::CEILING, '1.999', '200', '20', '2'],
1031
+ [RoundingMode::CEILING, '1.501', '151', '16', '2'],
1032
+ [RoundingMode::CEILING, '1.500', '150', '15', '2'],
1033
+ [RoundingMode::CEILING, '1.499', '150', '15', '2'],
1034
+ [RoundingMode::CEILING, '1.001', '101', '11', '2'],
1035
+ [RoundingMode::CEILING, '1.000', '100', '10', '1'],
1036
+ [RoundingMode::CEILING, '0.999', '100', '10', '1'],
1037
+ [RoundingMode::CEILING, '0.501', '51', '6', '1'],
1038
+ [RoundingMode::CEILING, '0.500', '50', '5', '1'],
1039
+ [RoundingMode::CEILING, '0.499', '50', '5', '1'],
1040
+ [RoundingMode::CEILING, '0.001', '1', '1', '1'],
1041
+ [RoundingMode::CEILING, '0.000', '0', '0', '0'],
1042
+ [RoundingMode::CEILING, '-0.001', '0', '0', '0'],
1043
+ [RoundingMode::CEILING, '-0.499', '-49' , '-4', '0'],
1044
+ [RoundingMode::CEILING, '-0.500', '-50' , '-5', '0'],
1045
+ [RoundingMode::CEILING, '-0.501', '-50', '-5', '0'],
1046
+ [RoundingMode::CEILING, '-0.999', '-99', '-9', '0'],
1047
+ [RoundingMode::CEILING, '-1.000', '-100', '-10', '-1'],
1048
+ [RoundingMode::CEILING, '-1.001', '-100', '-10', '-1'],
1049
+ [RoundingMode::CEILING, '-1.499', '-149', '-14', '-1'],
1050
+ [RoundingMode::CEILING, '-1.500', '-150', '-15', '-1'],
1051
+ [RoundingMode::CEILING, '-1.501', '-150', '-15', '-1'],
1052
+ [RoundingMode::CEILING, '-1.999', '-199', '-19', '-1'],
1053
+ [RoundingMode::CEILING, '-2.000', '-200', '-20', '-2'],
1054
+ [RoundingMode::CEILING, '-2.001', '-200', '-20', '-2'],
1055
+ [RoundingMode::CEILING, '-2.499', '-249', '-24', '-2'],
1056
+ [RoundingMode::CEILING, '-2.500', '-250', '-25', '-2'],
1057
+ [RoundingMode::CEILING, '-2.501', '-250', '-25', '-2'],
1058
+ [RoundingMode::CEILING, '-2.999', '-299', '-29', '-2'],
1059
+ [RoundingMode::CEILING, '-3.000', '-300', '-30', '-3'],
1060
+ [RoundingMode::CEILING, '-3.001', '-300', '-30', '-3'],
1061
+ [RoundingMode::CEILING, '-3.499', '-349', '-34', '-3'],
1062
+ [RoundingMode::CEILING, '-3.500', '-350', '-35', '-3'],
1063
+ [RoundingMode::CEILING, '-3.501', '-350', '-35', '-3'],
1064
+
1065
+ [RoundingMode::FLOOR, '3.501', '350', '35', '3'],
1066
+ [RoundingMode::FLOOR, '3.500', '350', '35', '3'],
1067
+ [RoundingMode::FLOOR, '3.499', '349', '34', '3'],
1068
+ [RoundingMode::FLOOR, '3.001', '300', '30', '3'],
1069
+ [RoundingMode::FLOOR, '3.000', '300', '30', '3'],
1070
+ [RoundingMode::FLOOR, '2.999', '299', '29', '2'],
1071
+ [RoundingMode::FLOOR, '2.501', '250', '25', '2'],
1072
+ [RoundingMode::FLOOR, '2.500', '250', '25', '2'],
1073
+ [RoundingMode::FLOOR, '2.499', '249', '24', '2'],
1074
+ [RoundingMode::FLOOR, '2.001', '200', '20', '2'],
1075
+ [RoundingMode::FLOOR, '2.000', '200', '20', '2'],
1076
+ [RoundingMode::FLOOR, '1.999', '199', '19', '1'],
1077
+ [RoundingMode::FLOOR, '1.501', '150', '15', '1'],
1078
+ [RoundingMode::FLOOR, '1.500', '150', '15', '1'],
1079
+ [RoundingMode::FLOOR, '1.499', '149', '14', '1'],
1080
+ [RoundingMode::FLOOR, '1.001', '100', '10', '1'],
1081
+ [RoundingMode::FLOOR, '1.000', '100', '10', '1'],
1082
+ [RoundingMode::FLOOR, '0.999', '99', '9', '0'],
1083
+ [RoundingMode::FLOOR, '0.501', '50', '5', '0'],
1084
+ [RoundingMode::FLOOR, '0.500', '50', '5', '0'],
1085
+ [RoundingMode::FLOOR, '0.499', '49', '4', '0'],
1086
+ [RoundingMode::FLOOR, '0.001', '0', '0', '0'],
1087
+ [RoundingMode::FLOOR, '0.000', '0', '0', '0'],
1088
+ [RoundingMode::FLOOR, '-0.001', '-1', '-1', '-1'],
1089
+ [RoundingMode::FLOOR, '-0.499', '-50', '-5', '-1'],
1090
+ [RoundingMode::FLOOR, '-0.500', '-50', '-5', '-1'],
1091
+ [RoundingMode::FLOOR, '-0.501', '-51', '-6', '-1'],
1092
+ [RoundingMode::FLOOR, '-0.999', '-100', '-10', '-1'],
1093
+ [RoundingMode::FLOOR, '-1.000', '-100', '-10', '-1'],
1094
+ [RoundingMode::FLOOR, '-1.001', '-101', '-11', '-2'],
1095
+ [RoundingMode::FLOOR, '-1.499', '-150', '-15', '-2'],
1096
+ [RoundingMode::FLOOR, '-1.500', '-150', '-15', '-2'],
1097
+ [RoundingMode::FLOOR, '-1.501', '-151', '-16', '-2'],
1098
+ [RoundingMode::FLOOR, '-1.999', '-200', '-20', '-2'],
1099
+ [RoundingMode::FLOOR, '-2.000', '-200', '-20', '-2'],
1100
+ [RoundingMode::FLOOR, '-2.001', '-201', '-21', '-3'],
1101
+ [RoundingMode::FLOOR, '-2.499', '-250', '-25', '-3'],
1102
+ [RoundingMode::FLOOR, '-2.500', '-250', '-25', '-3'],
1103
+ [RoundingMode::FLOOR, '-2.501', '-251', '-26', '-3'],
1104
+ [RoundingMode::FLOOR, '-2.999', '-300', '-30', '-3'],
1105
+ [RoundingMode::FLOOR, '-3.000', '-300', '-30', '-3'],
1106
+ [RoundingMode::FLOOR, '-3.001', '-301', '-31', '-4'],
1107
+ [RoundingMode::FLOOR, '-3.499', '-350', '-35', '-4'],
1108
+ [RoundingMode::FLOOR, '-3.500', '-350', '-35', '-4'],
1109
+ [RoundingMode::FLOOR, '-3.501', '-351', '-36', '-4'],
1110
+
1111
+ [RoundingMode::HALF_UP, '3.501', '350', '35', '4'],
1112
+ [RoundingMode::HALF_UP, '3.500', '350', '35', '4'],
1113
+ [RoundingMode::HALF_UP, '3.499', '350', '35', '3'],
1114
+ [RoundingMode::HALF_UP, '3.001', '300', '30', '3'],
1115
+ [RoundingMode::HALF_UP, '3.000', '300', '30', '3'],
1116
+ [RoundingMode::HALF_UP, '2.999', '300', '30', '3'],
1117
+ [RoundingMode::HALF_UP, '2.501', '250', '25', '3'],
1118
+ [RoundingMode::HALF_UP, '2.500', '250', '25', '3'],
1119
+ [RoundingMode::HALF_UP, '2.499', '250', '25', '2'],
1120
+ [RoundingMode::HALF_UP, '2.001', '200', '20', '2'],
1121
+ [RoundingMode::HALF_UP, '2.000', '200', '20', '2'],
1122
+ [RoundingMode::HALF_UP, '1.999', '200', '20', '2'],
1123
+ [RoundingMode::HALF_UP, '1.501', '150', '15', '2'],
1124
+ [RoundingMode::HALF_UP, '1.500', '150', '15', '2'],
1125
+ [RoundingMode::HALF_UP, '1.499', '150', '15', '1'],
1126
+ [RoundingMode::HALF_UP, '1.001', '100', '10', '1'],
1127
+ [RoundingMode::HALF_UP, '1.000', '100', '10', '1'],
1128
+ [RoundingMode::HALF_UP, '0.999', '100', '10', '1'],
1129
+ [RoundingMode::HALF_UP, '0.501', '50', '5', '1'],
1130
+ [RoundingMode::HALF_UP, '0.500', '50', '5', '1'],
1131
+ [RoundingMode::HALF_UP, '0.499', '50', '5', '0'],
1132
+ [RoundingMode::HALF_UP, '0.001', '0', '0', '0'],
1133
+ [RoundingMode::HALF_UP, '0.000', '0', '0', '0'],
1134
+ [RoundingMode::HALF_UP, '-0.001', '0', '0', '0'],
1135
+ [RoundingMode::HALF_UP, '-0.499', '-50', '-5', '0'],
1136
+ [RoundingMode::HALF_UP, '-0.500', '-50', '-5', '-1'],
1137
+ [RoundingMode::HALF_UP, '-0.501', '-50', '-5', '-1'],
1138
+ [RoundingMode::HALF_UP, '-0.999', '-100', '-10', '-1'],
1139
+ [RoundingMode::HALF_UP, '-1.000', '-100', '-10', '-1'],
1140
+ [RoundingMode::HALF_UP, '-1.001', '-100', '-10', '-1'],
1141
+ [RoundingMode::HALF_UP, '-1.499', '-150', '-15', '-1'],
1142
+ [RoundingMode::HALF_UP, '-1.500', '-150', '-15', '-2'],
1143
+ [RoundingMode::HALF_UP, '-1.501', '-150', '-15', '-2'],
1144
+ [RoundingMode::HALF_UP, '-1.999', '-200', '-20', '-2'],
1145
+ [RoundingMode::HALF_UP, '-2.000', '-200', '-20', '-2'],
1146
+ [RoundingMode::HALF_UP, '-2.001', '-200', '-20', '-2'],
1147
+ [RoundingMode::HALF_UP, '-2.499', '-250', '-25', '-2'],
1148
+ [RoundingMode::HALF_UP, '-2.500', '-250', '-25', '-3'],
1149
+ [RoundingMode::HALF_UP, '-2.501', '-250', '-25', '-3'],
1150
+ [RoundingMode::HALF_UP, '-2.999', '-300', '-30', '-3'],
1151
+ [RoundingMode::HALF_UP, '-3.000', '-300', '-30', '-3'],
1152
+ [RoundingMode::HALF_UP, '-3.001', '-300', '-30', '-3'],
1153
+ [RoundingMode::HALF_UP, '-3.499', '-350', '-35', '-3'],
1154
+ [RoundingMode::HALF_UP, '-3.500', '-350', '-35', '-4'],
1155
+ [RoundingMode::HALF_UP, '-3.501', '-350', '-35', '-4'],
1156
+
1157
+ [RoundingMode::HALF_DOWN, '3.501', '350', '35', '4'],
1158
+ [RoundingMode::HALF_DOWN, '3.500', '350', '35', '3'],
1159
+ [RoundingMode::HALF_DOWN, '3.499', '350', '35', '3'],
1160
+ [RoundingMode::HALF_DOWN, '3.001', '300', '30', '3'],
1161
+ [RoundingMode::HALF_DOWN, '3.000', '300', '30', '3'],
1162
+ [RoundingMode::HALF_DOWN, '2.999', '300', '30', '3'],
1163
+ [RoundingMode::HALF_DOWN, '2.501', '250', '25', '3'],
1164
+ [RoundingMode::HALF_DOWN, '2.500', '250', '25', '2'],
1165
+ [RoundingMode::HALF_DOWN, '2.499', '250', '25', '2'],
1166
+ [RoundingMode::HALF_DOWN, '2.001', '200', '20', '2'],
1167
+ [RoundingMode::HALF_DOWN, '2.000', '200', '20', '2'],
1168
+ [RoundingMode::HALF_DOWN, '1.999', '200', '20', '2'],
1169
+ [RoundingMode::HALF_DOWN, '1.501', '150', '15', '2'],
1170
+ [RoundingMode::HALF_DOWN, '1.500', '150', '15', '1'],
1171
+ [RoundingMode::HALF_DOWN, '1.499', '150', '15', '1'],
1172
+ [RoundingMode::HALF_DOWN, '1.001', '100', '10', '1'],
1173
+ [RoundingMode::HALF_DOWN, '1.000', '100', '10', '1'],
1174
+ [RoundingMode::HALF_DOWN, '0.999', '100', '10', '1'],
1175
+ [RoundingMode::HALF_DOWN, '0.501', '50', '5', '1'],
1176
+ [RoundingMode::HALF_DOWN, '0.500', '50', '5', '0'],
1177
+ [RoundingMode::HALF_DOWN, '0.499', '50', '5', '0'],
1178
+ [RoundingMode::HALF_DOWN, '0.001', '0', '0', '0'],
1179
+ [RoundingMode::HALF_DOWN, '0.000', '0', '0', '0'],
1180
+ [RoundingMode::HALF_DOWN, '-0.001', '0', '0', '0'],
1181
+ [RoundingMode::HALF_DOWN, '-0.499', '-50', '-5', '0'],
1182
+ [RoundingMode::HALF_DOWN, '-0.500', '-50', '-5', '0'],
1183
+ [RoundingMode::HALF_DOWN, '-0.501', '-50', '-5', '-1'],
1184
+ [RoundingMode::HALF_DOWN, '-0.999', '-100', '-10', '-1'],
1185
+ [RoundingMode::HALF_DOWN, '-1.000', '-100', '-10', '-1'],
1186
+ [RoundingMode::HALF_DOWN, '-1.001', '-100', '-10', '-1'],
1187
+ [RoundingMode::HALF_DOWN, '-1.499', '-150', '-15', '-1'],
1188
+ [RoundingMode::HALF_DOWN, '-1.500', '-150', '-15', '-1'],
1189
+ [RoundingMode::HALF_DOWN, '-1.501', '-150', '-15', '-2'],
1190
+ [RoundingMode::HALF_DOWN, '-1.999', '-200', '-20', '-2'],
1191
+ [RoundingMode::HALF_DOWN, '-2.000', '-200', '-20', '-2'],
1192
+ [RoundingMode::HALF_DOWN, '-2.001', '-200', '-20', '-2'],
1193
+ [RoundingMode::HALF_DOWN, '-2.499', '-250', '-25', '-2'],
1194
+ [RoundingMode::HALF_DOWN, '-2.500', '-250', '-25', '-2'],
1195
+ [RoundingMode::HALF_DOWN, '-2.501', '-250', '-25', '-3'],
1196
+ [RoundingMode::HALF_DOWN, '-2.999', '-300', '-30', '-3'],
1197
+ [RoundingMode::HALF_DOWN, '-3.000', '-300', '-30', '-3'],
1198
+ [RoundingMode::HALF_DOWN, '-3.001', '-300', '-30', '-3'],
1199
+ [RoundingMode::HALF_DOWN, '-3.499', '-350', '-35', '-3'],
1200
+ [RoundingMode::HALF_DOWN, '-3.500', '-350', '-35', '-3'],
1201
+ [RoundingMode::HALF_DOWN, '-3.501', '-350', '-35', '-4'],
1202
+
1203
+ [RoundingMode::HALF_CEILING, '3.501', '350', '35', '4'],
1204
+ [RoundingMode::HALF_CEILING, '3.500', '350', '35', '4'],
1205
+ [RoundingMode::HALF_CEILING, '3.499', '350', '35', '3'],
1206
+ [RoundingMode::HALF_CEILING, '3.001', '300', '30', '3'],
1207
+ [RoundingMode::HALF_CEILING, '3.000', '300', '30', '3'],
1208
+ [RoundingMode::HALF_CEILING, '2.999', '300', '30', '3'],
1209
+ [RoundingMode::HALF_CEILING, '2.501', '250', '25', '3'],
1210
+ [RoundingMode::HALF_CEILING, '2.500', '250', '25', '3'],
1211
+ [RoundingMode::HALF_CEILING, '2.499', '250', '25', '2'],
1212
+ [RoundingMode::HALF_CEILING, '2.001', '200', '20', '2'],
1213
+ [RoundingMode::HALF_CEILING, '2.000', '200', '20', '2'],
1214
+ [RoundingMode::HALF_CEILING, '1.999', '200', '20', '2'],
1215
+ [RoundingMode::HALF_CEILING, '1.501', '150', '15', '2'],
1216
+ [RoundingMode::HALF_CEILING, '1.500', '150', '15', '2'],
1217
+ [RoundingMode::HALF_CEILING, '1.499', '150', '15', '1'],
1218
+ [RoundingMode::HALF_CEILING, '1.001', '100', '10', '1'],
1219
+ [RoundingMode::HALF_CEILING, '1.000', '100', '10', '1'],
1220
+ [RoundingMode::HALF_CEILING, '0.999', '100', '10', '1'],
1221
+ [RoundingMode::HALF_CEILING, '0.501', '50', '5', '1'],
1222
+ [RoundingMode::HALF_CEILING, '0.500', '50', '5', '1'],
1223
+ [RoundingMode::HALF_CEILING, '0.499', '50', '5', '0'],
1224
+ [RoundingMode::HALF_CEILING, '0.001', '0', '0', '0'],
1225
+ [RoundingMode::HALF_CEILING, '0.000', '0', '0', '0'],
1226
+ [RoundingMode::HALF_CEILING, '-0.001', '0', '0', '0'],
1227
+ [RoundingMode::HALF_CEILING, '-0.499', '-50', '-5', '0'],
1228
+ [RoundingMode::HALF_CEILING, '-0.500', '-50', '-5', '0'],
1229
+ [RoundingMode::HALF_CEILING, '-0.501', '-50', '-5', '-1'],
1230
+ [RoundingMode::HALF_CEILING, '-0.999', '-100', '-10', '-1'],
1231
+ [RoundingMode::HALF_CEILING, '-1.000', '-100', '-10', '-1'],
1232
+ [RoundingMode::HALF_CEILING, '-1.001', '-100', '-10', '-1'],
1233
+ [RoundingMode::HALF_CEILING, '-1.499', '-150', '-15', '-1'],
1234
+ [RoundingMode::HALF_CEILING, '-1.500', '-150', '-15', '-1'],
1235
+ [RoundingMode::HALF_CEILING, '-1.501', '-150', '-15', '-2'],
1236
+ [RoundingMode::HALF_CEILING, '-1.999', '-200', '-20', '-2'],
1237
+ [RoundingMode::HALF_CEILING, '-2.000', '-200', '-20', '-2'],
1238
+ [RoundingMode::HALF_CEILING, '-2.001', '-200', '-20', '-2'],
1239
+ [RoundingMode::HALF_CEILING, '-2.499', '-250', '-25', '-2'],
1240
+ [RoundingMode::HALF_CEILING, '-2.500', '-250', '-25', '-2'],
1241
+ [RoundingMode::HALF_CEILING, '-2.501', '-250', '-25', '-3'],
1242
+ [RoundingMode::HALF_CEILING, '-2.999', '-300', '-30', '-3'],
1243
+ [RoundingMode::HALF_CEILING, '-3.000', '-300', '-30', '-3'],
1244
+ [RoundingMode::HALF_CEILING, '-3.001', '-300', '-30', '-3'],
1245
+ [RoundingMode::HALF_CEILING, '-3.499', '-350', '-35', '-3'],
1246
+ [RoundingMode::HALF_CEILING, '-3.500', '-350', '-35', '-3'],
1247
+ [RoundingMode::HALF_CEILING, '-3.501', '-350', '-35', '-4'],
1248
+
1249
+ [RoundingMode::HALF_FLOOR, '3.501', '350', '35', '4'],
1250
+ [RoundingMode::HALF_FLOOR, '3.500', '350', '35', '3'],
1251
+ [RoundingMode::HALF_FLOOR, '3.499', '350', '35', '3'],
1252
+ [RoundingMode::HALF_FLOOR, '3.001', '300', '30', '3'],
1253
+ [RoundingMode::HALF_FLOOR, '3.000', '300', '30', '3'],
1254
+ [RoundingMode::HALF_FLOOR, '2.999', '300', '30', '3'],
1255
+ [RoundingMode::HALF_FLOOR, '2.501', '250', '25', '3'],
1256
+ [RoundingMode::HALF_FLOOR, '2.500', '250', '25', '2'],
1257
+ [RoundingMode::HALF_FLOOR, '2.499', '250', '25', '2'],
1258
+ [RoundingMode::HALF_FLOOR, '2.001', '200', '20', '2'],
1259
+ [RoundingMode::HALF_FLOOR, '2.000', '200', '20', '2'],
1260
+ [RoundingMode::HALF_FLOOR, '1.999', '200', '20', '2'],
1261
+ [RoundingMode::HALF_FLOOR, '1.501', '150', '15', '2'],
1262
+ [RoundingMode::HALF_FLOOR, '1.500', '150', '15', '1'],
1263
+ [RoundingMode::HALF_FLOOR, '1.499', '150', '15', '1'],
1264
+ [RoundingMode::HALF_FLOOR, '1.001', '100', '10', '1'],
1265
+ [RoundingMode::HALF_FLOOR, '1.000', '100', '10', '1'],
1266
+ [RoundingMode::HALF_FLOOR, '0.999', '100', '10', '1'],
1267
+ [RoundingMode::HALF_FLOOR, '0.501', '50', '5', '1'],
1268
+ [RoundingMode::HALF_FLOOR, '0.500', '50', '5', '0'],
1269
+ [RoundingMode::HALF_FLOOR, '0.499', '50', '5', '0'],
1270
+ [RoundingMode::HALF_FLOOR, '0.001', '0', '0', '0'],
1271
+ [RoundingMode::HALF_FLOOR, '0.000', '0', '0', '0'],
1272
+ [RoundingMode::HALF_FLOOR, '-0.001', '0', '0', '0'],
1273
+ [RoundingMode::HALF_FLOOR, '-0.499', '-50', '-5', '0'],
1274
+ [RoundingMode::HALF_FLOOR, '-0.500', '-50', '-5', '-1'],
1275
+ [RoundingMode::HALF_FLOOR, '-0.501', '-50', '-5', '-1'],
1276
+ [RoundingMode::HALF_FLOOR, '-0.999', '-100', '-10', '-1'],
1277
+ [RoundingMode::HALF_FLOOR, '-1.000', '-100', '-10', '-1'],
1278
+ [RoundingMode::HALF_FLOOR, '-1.001', '-100', '-10', '-1'],
1279
+ [RoundingMode::HALF_FLOOR, '-1.499', '-150', '-15', '-1'],
1280
+ [RoundingMode::HALF_FLOOR, '-1.500', '-150', '-15', '-2'],
1281
+ [RoundingMode::HALF_FLOOR, '-1.501', '-150', '-15', '-2'],
1282
+ [RoundingMode::HALF_FLOOR, '-1.999', '-200', '-20', '-2'],
1283
+ [RoundingMode::HALF_FLOOR, '-2.000', '-200', '-20', '-2'],
1284
+ [RoundingMode::HALF_FLOOR, '-2.001', '-200', '-20', '-2'],
1285
+ [RoundingMode::HALF_FLOOR, '-2.499', '-250', '-25', '-2'],
1286
+ [RoundingMode::HALF_FLOOR, '-2.500', '-250', '-25', '-3'],
1287
+ [RoundingMode::HALF_FLOOR, '-2.501', '-250', '-25', '-3'],
1288
+ [RoundingMode::HALF_FLOOR, '-2.999', '-300', '-30', '-3'],
1289
+ [RoundingMode::HALF_FLOOR, '-3.000', '-300', '-30', '-3'],
1290
+ [RoundingMode::HALF_FLOOR, '-3.001', '-300', '-30', '-3'],
1291
+ [RoundingMode::HALF_FLOOR, '-3.499', '-350', '-35', '-3'],
1292
+ [RoundingMode::HALF_FLOOR, '-3.500', '-350', '-35', '-4'],
1293
+ [RoundingMode::HALF_FLOOR, '-3.501', '-350', '-35', '-4'],
1294
+
1295
+ [RoundingMode::HALF_EVEN, '3.501', '350', '35', '4'],
1296
+ [RoundingMode::HALF_EVEN, '3.500', '350', '35', '4'],
1297
+ [RoundingMode::HALF_EVEN, '3.499', '350', '35', '3'],
1298
+ [RoundingMode::HALF_EVEN, '3.001', '300', '30', '3'],
1299
+ [RoundingMode::HALF_EVEN, '3.000', '300', '30', '3'],
1300
+ [RoundingMode::HALF_EVEN, '2.999', '300', '30', '3'],
1301
+ [RoundingMode::HALF_EVEN, '2.501', '250', '25', '3'],
1302
+ [RoundingMode::HALF_EVEN, '2.500', '250', '25', '2'],
1303
+ [RoundingMode::HALF_EVEN, '2.499', '250', '25', '2'],
1304
+ [RoundingMode::HALF_EVEN, '2.001', '200', '20', '2'],
1305
+ [RoundingMode::HALF_EVEN, '2.000', '200', '20', '2'],
1306
+ [RoundingMode::HALF_EVEN, '1.999', '200', '20', '2'],
1307
+ [RoundingMode::HALF_EVEN, '1.501', '150', '15', '2'],
1308
+ [RoundingMode::HALF_EVEN, '1.500', '150', '15', '2'],
1309
+ [RoundingMode::HALF_EVEN, '1.499', '150', '15', '1'],
1310
+ [RoundingMode::HALF_EVEN, '1.001', '100', '10', '1'],
1311
+ [RoundingMode::HALF_EVEN, '1.000', '100', '10', '1'],
1312
+ [RoundingMode::HALF_EVEN, '0.999', '100', '10', '1'],
1313
+ [RoundingMode::HALF_EVEN, '0.501', '50', '5', '1'],
1314
+ [RoundingMode::HALF_EVEN, '0.500', '50', '5', '0'],
1315
+ [RoundingMode::HALF_EVEN, '0.499', '50', '5', '0'],
1316
+ [RoundingMode::HALF_EVEN, '0.001', '0', '0', '0'],
1317
+ [RoundingMode::HALF_EVEN, '0.000', '0', '0', '0'],
1318
+ [RoundingMode::HALF_EVEN, '-0.001', '0', '0', '0'],
1319
+ [RoundingMode::HALF_EVEN, '-0.499', '-50', '-5', '0'],
1320
+ [RoundingMode::HALF_EVEN, '-0.500', '-50', '-5', '0'],
1321
+ [RoundingMode::HALF_EVEN, '-0.501', '-50', '-5', '-1'],
1322
+ [RoundingMode::HALF_EVEN, '-0.999', '-100', '-10', '-1'],
1323
+ [RoundingMode::HALF_EVEN, '-1.000', '-100', '-10', '-1'],
1324
+ [RoundingMode::HALF_EVEN, '-1.001', '-100', '-10', '-1'],
1325
+ [RoundingMode::HALF_EVEN, '-1.499', '-150', '-15', '-1'],
1326
+ [RoundingMode::HALF_EVEN, '-1.500', '-150', '-15', '-2'],
1327
+ [RoundingMode::HALF_EVEN, '-1.501', '-150', '-15', '-2'],
1328
+ [RoundingMode::HALF_EVEN, '-1.999', '-200', '-20', '-2'],
1329
+ [RoundingMode::HALF_EVEN, '-2.000', '-200', '-20', '-2'],
1330
+ [RoundingMode::HALF_EVEN, '-2.001', '-200', '-20', '-2'],
1331
+ [RoundingMode::HALF_EVEN, '-2.499', '-250', '-25', '-2'],
1332
+ [RoundingMode::HALF_EVEN, '-2.500', '-250', '-25', '-2'],
1333
+ [RoundingMode::HALF_EVEN, '-2.501', '-250', '-25', '-3'],
1334
+ [RoundingMode::HALF_EVEN, '-2.999', '-300', '-30', '-3'],
1335
+ [RoundingMode::HALF_EVEN, '-3.000', '-300', '-30', '-3'],
1336
+ [RoundingMode::HALF_EVEN, '-3.001', '-300', '-30', '-3'],
1337
+ [RoundingMode::HALF_EVEN, '-3.499', '-350', '-35', '-3'],
1338
+ [RoundingMode::HALF_EVEN, '-3.500', '-350', '-35', '-4'],
1339
+ [RoundingMode::HALF_EVEN, '-3.501', '-350', '-35', '-4'],
1340
+
1341
+ [RoundingMode::UNNECESSARY, '3.501', null, null, null],
1342
+ [RoundingMode::UNNECESSARY, '3.500', '350', '35', null],
1343
+ [RoundingMode::UNNECESSARY, '3.499', null, null, null],
1344
+ [RoundingMode::UNNECESSARY, '3.001', null, null, null],
1345
+ [RoundingMode::UNNECESSARY, '3.000', '300', '30', '3'],
1346
+ [RoundingMode::UNNECESSARY, '2.999', null, null, null],
1347
+ [RoundingMode::UNNECESSARY, '2.501', null, null, null],
1348
+ [RoundingMode::UNNECESSARY, '2.500', '250', '25', null],
1349
+ [RoundingMode::UNNECESSARY, '2.499', null, null, null],
1350
+ [RoundingMode::UNNECESSARY, '2.001', null, null, null],
1351
+ [RoundingMode::UNNECESSARY, '2.000', '200', '20', '2'],
1352
+ [RoundingMode::UNNECESSARY, '1.999', null, null, null],
1353
+ [RoundingMode::UNNECESSARY, '1.501', null, null, null],
1354
+ [RoundingMode::UNNECESSARY, '1.500', '150', '15', null],
1355
+ [RoundingMode::UNNECESSARY, '1.499', null, null, null],
1356
+ [RoundingMode::UNNECESSARY, '1.001', null, null, null],
1357
+ [RoundingMode::UNNECESSARY, '1.000', '100', '10', '1'],
1358
+ [RoundingMode::UNNECESSARY, '0.999', null, null, null],
1359
+ [RoundingMode::UNNECESSARY, '0.501', null, null, null],
1360
+ [RoundingMode::UNNECESSARY, '0.500', '50', '5', null],
1361
+ [RoundingMode::UNNECESSARY, '0.499', null, null, null],
1362
+ [RoundingMode::UNNECESSARY, '0.001', null, null, null],
1363
+ [RoundingMode::UNNECESSARY, '0.000', '0', '0', '0'],
1364
+ [RoundingMode::UNNECESSARY, '-0.001', null, null, null],
1365
+ [RoundingMode::UNNECESSARY, '-0.499', null, null, null],
1366
+ [RoundingMode::UNNECESSARY, '-0.500', '-50', '-5', null],
1367
+ [RoundingMode::UNNECESSARY, '-0.501', null, null, null],
1368
+ [RoundingMode::UNNECESSARY, '-0.999', null, null, null],
1369
+ [RoundingMode::UNNECESSARY, '-1.000', '-100', '-10', '-1'],
1370
+ [RoundingMode::UNNECESSARY, '-1.001', null, null, null],
1371
+ [RoundingMode::UNNECESSARY, '-1.499', null, null, null],
1372
+ [RoundingMode::UNNECESSARY, '-1.500', '-150', '-15', null],
1373
+ [RoundingMode::UNNECESSARY, '-1.501', null, null, null],
1374
+ [RoundingMode::UNNECESSARY, '-1.999', null, null, null],
1375
+ [RoundingMode::UNNECESSARY, '-2.000', '-200', '-20', '-2'],
1376
+ [RoundingMode::UNNECESSARY, '-2.001', null, null, null],
1377
+ [RoundingMode::UNNECESSARY, '-2.499', null, null, null],
1378
+ [RoundingMode::UNNECESSARY, '-2.500', '-250', '-25', null],
1379
+ [RoundingMode::UNNECESSARY, '-2.501', null, null, null],
1380
+ [RoundingMode::UNNECESSARY, '-2.999', null, null, null],
1381
+ [RoundingMode::UNNECESSARY, '-3.000', '-300', '-30', '-3'],
1382
+ [RoundingMode::UNNECESSARY, '-3.001', null, null, null],
1383
+ [RoundingMode::UNNECESSARY, '-3.499', null, null, null],
1384
+ [RoundingMode::UNNECESSARY, '-3.500', '-350', '-35', null],
1385
+ [RoundingMode::UNNECESSARY, '-3.501', null, null, null],
1386
+ ];
1387
+ }
1388
+
1389
+ /**
1390
+ * @dataProvider providerQuotientAndRemainder
1391
+ *
1392
+ * @param string $dividend The dividend.
1393
+ * @param string $divisor The divisor.
1394
+ * @param string $quotient The expected quotient.
1395
+ * @param string $remainder The expected remainder.
1396
+ */
1397
+ public function testQuotientAndRemainder(string $dividend, string $divisor, string $quotient, string $remainder) : void
1398
+ {
1399
+ $dividend = BigDecimal::of($dividend);
1400
+
1401
+ self::assertBigDecimalEquals($quotient, $dividend->quotient($divisor));
1402
+ self::assertBigDecimalEquals($remainder, $dividend->remainder($divisor));
1403
+
1404
+ [$q, $r] = $dividend->quotientAndRemainder($divisor);
1405
+
1406
+ self::assertBigDecimalEquals($quotient, $q);
1407
+ self::assertBigDecimalEquals($remainder, $r);
1408
+ }
1409
+
1410
+ public function providerQuotientAndRemainder() : array
1411
+ {
1412
+ return [
1413
+ ['1', '123', '0', '1'],
1414
+ ['1', '-123', '0', '1'],
1415
+ ['-1', '123', '0', '-1'],
1416
+ ['-1', '-123', '0', '-1'],
1417
+
1418
+ ['1999999999999999999999999', '2000000000000000000000000', '0', '1999999999999999999999999'],
1419
+ ['1999999999999999999999999', '-2000000000000000000000000', '0', '1999999999999999999999999'],
1420
+ ['-1999999999999999999999999', '2000000000000000000000000', '0', '-1999999999999999999999999'],
1421
+ ['-1999999999999999999999999', '-2000000000000000000000000', '0', '-1999999999999999999999999'],
1422
+
1423
+ ['123', '1', '123', '0'],
1424
+ ['123', '-1', '-123', '0'],
1425
+ ['-123', '1', '-123', '0'],
1426
+ ['-123', '-1', '123', '0'],
1427
+
1428
+ ['123', '2', '61', '1'],
1429
+ ['123', '-2', '-61', '1'],
1430
+ ['-123', '2', '-61', '-1'],
1431
+ ['-123', '-2', '61', '-1'],
1432
+
1433
+ ['123', '123', '1', '0'],
1434
+ ['123', '-123', '-1', '0'],
1435
+ ['-123', '123', '-1', '0'],
1436
+ ['-123', '-123', '1', '0'],
1437
+
1438
+ ['123', '124', '0', '123'],
1439
+ ['123', '-124', '0', '123'],
1440
+ ['-123', '124', '0', '-123'],
1441
+ ['-123', '-124', '0', '-123'],
1442
+
1443
+ ['124', '123', '1', '1'],
1444
+ ['124', '-123', '-1', '1'],
1445
+ ['-124', '123', '-1', '-1'],
1446
+ ['-124', '-123', '1', '-1'],
1447
+
1448
+ ['1000000000000000000000000000000', '3', '333333333333333333333333333333', '1'],
1449
+ ['1000000000000000000000000000000', '9', '111111111111111111111111111111', '1'],
1450
+ ['1000000000000000000000000000000', '11', '90909090909090909090909090909', '1'],
1451
+ ['1000000000000000000000000000000', '13', '76923076923076923076923076923', '1'],
1452
+ ['1000000000000000000000000000000', '21', '47619047619047619047619047619', '1'],
1453
+
1454
+ ['123456789123456789123456789', '987654321987654321', '124999998', '850308642973765431'],
1455
+ ['123456789123456789123456789', '-87654321987654321', '-1408450676', '65623397056685793'],
1456
+ ['-123456789123456789123456789', '7654321987654321', '-16129030020', '-1834176331740369'],
1457
+ ['-123456789123456789123456789', '-654321987654321', '188678955396', '-205094497790673'],
1458
+
1459
+ ['10.11', '3.3', '3', '0.21'],
1460
+ ['1', '-0.0013', '-769', '0.0003'],
1461
+ ['-1.000000000000000000001', '0.0000009298439898981609', '-1075449', '-0.0000002109080127582569'],
1462
+ ['-1278438782896060000132323.32333', '-53.4836775545640521556878910541', '23903344746475158719036', '-30.0786684482104867175202241524'],
1463
+ ['23999593472872987498347103908209387429846376', '-0.005', '-4799918694574597499669420781641877485969275200', '0.000'],
1464
+
1465
+ ['1000000000000000000000000000000.0', '3', '333333333333333333333333333333', '1.0'],
1466
+ ['1000000000000000000000000000000.0', '9', '111111111111111111111111111111', '1.0'],
1467
+ ['1000000000000000000000000000000.0', '11', '90909090909090909090909090909', '1.0'],
1468
+ ['1000000000000000000000000000000.0', '13', '76923076923076923076923076923', '1.0'],
1469
+ ['0.9999999999999999999999999999999', '0.21', '4', '0.1599999999999999999999999999999'],
1470
+
1471
+ ['1000000000000000000000000000000.0', '3.9', '256410256410256410256410256410', '1.0'],
1472
+ ['-1000000000000000000000000000000.0', '9.8', '-102040816326530612244897959183', '-6.6'],
1473
+ ['1000000000000000000000000000000.0', '-11.7', '-85470085470085470085470085470', '1.0'],
1474
+ ['-1000000000000000000000000000000.0', '-13.7', '72992700729927007299270072992', '-9.6'],
1475
+ ['0.99999999999999999999999999999999', '0.215', '4', '0.13999999999999999999999999999999'],
1476
+ ];
1477
+ }
1478
+
1479
+ public function testQuotientOfZeroThrowsException() : void
1480
+ {
1481
+ $this->expectException(DivisionByZeroException::class);
1482
+ BigDecimal::of(1.2)->quotient(0);
1483
+ }
1484
+
1485
+ public function testRemainderOfZeroThrowsException() : void
1486
+ {
1487
+ $this->expectException(DivisionByZeroException::class);
1488
+ BigDecimal::of(1.2)->remainder(0);
1489
+ }
1490
+
1491
+ public function testQuotientAndRemainderOfZeroThrowsException() : void
1492
+ {
1493
+ $this->expectException(DivisionByZeroException::class);
1494
+ BigDecimal::of(1.2)->quotientAndRemainder(0);
1495
+ }
1496
+
1497
+ /**
1498
+ * @dataProvider providerSqrt
1499
+ */
1500
+ public function testSqrt(string $number, int $scale, string $sqrt) : void
1501
+ {
1502
+ $number = BigDecimal::of($number);
1503
+
1504
+ self::assertBigDecimalEquals($sqrt, $number->sqrt($scale));
1505
+ }
1506
+
1507
+ public function providerSqrt() : array
1508
+ {
1509
+ return [
1510
+ ['0', 0, '0'],
1511
+ ['0', 1, '0.0'],
1512
+ ['0', 2, '0.00'],
1513
+ ['0.9', 0, '0'],
1514
+ ['0.9', 1, '0.9'],
1515
+ ['0.9', 2, '0.94'],
1516
+ ['0.9', 20, '0.94868329805051379959'],
1517
+
1518
+ ['1', 0, '1'],
1519
+ ['1', 1, '1.0'],
1520
+ ['1', 2, '1.00'],
1521
+ ['1.01', 0, '1'],
1522
+ ['1.01', 1, '1.0'],
1523
+ ['1.01', 2, '1.00'],
1524
+ ['1.01', 50, '1.00498756211208902702192649127595761869450234700263'],
1525
+
1526
+ ['2', 0, '1'],
1527
+ ['2', 1, '1.4'],
1528
+ ['2', 2, '1.41'],
1529
+ ['2', 3, '1.414'],
1530
+ ['2.0', 10, '1.4142135623'],
1531
+ ['2.00', 100, '1.4142135623730950488016887242096980785696718753769480731766797379907324784621070388503875343276415727'],
1532
+ ['2.01', 100, '1.4177446878757825202955618542708577926112284524295925478183838620667251915680282359142910339946198902'],
1533
+
1534
+ ['3', 0, '1'],
1535
+ ['3', 1, '1.7'],
1536
+ ['3', 2, '1.73'],
1537
+ ['3.0', 3, '1.732'],
1538
+ ['3.00', 100, '1.7320508075688772935274463415058723669428052538103806280558069794519330169088000370811461867572485756'],
1539
+ ['3.01', 100, '1.7349351572897472412324994276999816954904345949805056180301062018688462654791174593725963060697252989'],
1540
+
1541
+ ['4', 0, '2'],
1542
+ ['4.0', 1, '2.0'],
1543
+ ['4.00', 2, '2.00'],
1544
+ ['4.000', 50, '2.00000000000000000000000000000000000000000000000000'],
1545
+ ['4.001', 50, '2.00024998437695281987761450010498155779765165614814'],
1546
+
1547
+ ['8', 0, '2'],
1548
+ ['8', 1, '2.8'],
1549
+ ['8', 2, '2.82'],
1550
+ ['8', 3, '2.828'],
1551
+ ['8', 100, '2.8284271247461900976033774484193961571393437507538961463533594759814649569242140777007750686552831454'],
1552
+
1553
+ ['9', 0, '3'],
1554
+ ['9', 1, '3.0'],
1555
+ ['9', 2, '3.00'],
1556
+ ['9.0', 3, '3.000'],
1557
+ ['9.00', 50, '3.00000000000000000000000000000000000000000000000000'],
1558
+ ['9.000000000001', 100, '3.0000000000001666666666666620370370370372942386831275541552354823973654295585021450670206100119695201'],
1559
+
1560
+ ['15', 0, '3'],
1561
+ ['15', 1, '3.8'],
1562
+ ['15', 2, '3.87'],
1563
+ ['15', 3, '3.872'],
1564
+ ['15', 100, '3.8729833462074168851792653997823996108329217052915908265875737661134830919369790335192873768586735179'],
1565
+
1566
+ ['16', 0, '4'],
1567
+ ['16', 1, '4.0'],
1568
+ ['16.0', 2, '4.00'],
1569
+ ['16.0', 50, '4.00000000000000000000000000000000000000000000000000'],
1570
+ ['16.9', 100, '4.1109609582188931315985616077625340938354216811227818749147563086303727702310096877475225408930903837'],
1571
+
1572
+ ['24.000000', 0, '4'],
1573
+ ['24.000000', 1, '4.8'],
1574
+ ['24.000000', 100, '4.8989794855663561963945681494117827839318949613133402568653851345019207549146300530797188662092804696'],
1575
+
1576
+ ['25.0', 0, '5'],
1577
+ ['25.0', 1, '5.0'],
1578
+ ['25.0', 2, '5.00'],
1579
+ ['25.0', 50, '5.00000000000000000000000000000000000000000000000000'],
1580
+
1581
+ ['35.0', 0, '5'],
1582
+ ['35.0', 1, '5.9'],
1583
+ ['35.0', 2, '5.91'],
1584
+ ['35.0', 3, '5.916'],
1585
+ ['35.0', 4, '5.9160'],
1586
+ ['35.0', 5, '5.91607'],
1587
+ ['35.0', 100, '5.9160797830996160425673282915616170484155012307943403228797196691428224591056530367657525271831091780'],
1588
+ ['35.000000000000001', 100, '5.9160797830996161270827537644132741956957234470198942745396537100863774127246283998019188486148209315'],
1589
+ ['35.999999999999999999999999', 100, '5.9999999999999999999999999166666666666666666666666660879629629629629629629629549254115226337448559670'],
1590
+
1591
+ ['36.00', 0, '6'],
1592
+ ['36.00', 1, '6.0'],
1593
+ ['36.00', 2, '6.00'],
1594
+ ['36.00', 3, '6.000'],
1595
+ ['36.00', 50, '6.00000000000000000000000000000000000000000000000000'],
1596
+
1597
+ ['48.00', 0, '6'],
1598
+ ['48.00', 2, '6.92'],
1599
+ ['48.00', 10, '6.9282032302'],
1600
+ ['48.00', 100, '6.9282032302755091741097853660234894677712210152415225122232279178077320676352001483245847470289943027'],
1601
+ ['48.99', 100, '6.9992856778388464346356995151906110076016504604210370025102717611026824990288822856842902895079113686'],
1602
+
1603
+ ['49.000', 0, '7'],
1604
+ ['49.000', 1, '7.0'],
1605
+ ['49.000', 2, '7.00'],
1606
+ ['49.000', 50, '7.00000000000000000000000000000000000000000000000000'],
1607
+
1608
+ ['63.000', 0, '7'],
1609
+ ['63.000', 1, '7.9'],
1610
+ ['63.000', 50, '7.93725393319377177150484726091778127713077754924735'],
1611
+ ['63.000', 100, '7.9372539331937717715048472609177812771307775492473505411050033776032064696908508832811786594236308318'],
1612
+ ['63.999', 100, '7.9999374997558574676327405322784897796491608172719005229581557200716046333750586163480165729931946120'],
1613
+
1614
+ ['64.000', 0, '8'],
1615
+ ['64.000', 1, '8.0'],
1616
+ ['64.000', 2, '8.00'],
1617
+ ['64.000', 3, '8.000'],
1618
+ ['64.000', 5, '8.00000'],
1619
+ ['64.000', 10, '8.0000000000'],
1620
+ ['64.001', 100, '8.0000624997558612823300065647321162325407871131077227756517693705917932138407362275702583154308502098'],
1621
+
1622
+ ['80.0000', 0, '8'],
1623
+ ['80.0000', 1, '8.9'],
1624
+ ['80.0000', 2, '8.94'],
1625
+ ['80.0000', 3, '8.944'],
1626
+ ['80.0000', 100, '8.9442719099991587856366946749251049417624734384461028970835889816420837025512195976576576335151290998'],
1627
+ ['80.9999', 100, '8.9999944444427297657453970731875168384468609868424736666730189165386046474591090720552569708711327582'],
1628
+
1629
+ ['81.0000', 0, '9'],
1630
+ ['81.0000', 1, '9.0'],
1631
+ ['81.0000', 2, '9.00'],
1632
+ ['81.0000', 3, '9.000'],
1633
+ ['81.0000', 100, '9.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000'],
1634
+ ['81.0001', 100, '9.0000055555538408789733941603538253684017661110877201067416238610513773808272313229667905649560045446'],
1635
+
1636
+ ['99.0000', 0, '9'],
1637
+ ['99.0000', 1, '9.9'],
1638
+ ['99.0000', 2, '9.94'],
1639
+ ['99.0000', 3, '9.949'],
1640
+ ['99.0000', 100, '9.9498743710661995473447982100120600517812656367680607911760464383494539278271315401265301973848719527'],
1641
+ ['99.9999', 100, '9.9999949999987499993749996093747265622949217138670565794807433154677543830170797681772155388691566433'],
1642
+
1643
+ ['100.00000', 0, '10'],
1644
+ ['100.00000', 1, '10.0'],
1645
+ ['100.00000', 2, '10.00'],
1646
+ ['100.00000', 3, '10.000'],
1647
+ ['100.00000', 100, '10.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000'],
1648
+ ['100.00001', 100, '10.0000004999999875000006249999609375027343747949218911132799407960075378325233467481612458396019939178'],
1649
+
1650
+ ['536137214136734800142146901786039940282473271927911507640625', 100, '732213912826528310663262741625.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000'],
1651
+ ['536137214136734800142146901787504368108126328549238033123875', 100, '732213912826528310663262741625.9999999999999999999999999999993171394434860226777473099041602996062918768042176806905944729779944325'],
1652
+ ['536137214136734800142146901787504368108126328549238033123876', 100, '732213912826528310663262741626.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000'],
1653
+ ['5651495859544574019979802175954184725583245698990648064256.0000000001', 100, '75176431543034642899535752016.0000000000000000000000000000000000000006651020668808623891656648072197795077909627885735661691784990'],
1654
+ ['5651495859544574019979802176104537588669314984789719568288.9999999999', 100, '75176431543034642899535752016.9999999999999999999999999999999999999993348979331191376108343351927890677073964211143577833889761307'],
1655
+ ['5651495859544574019979802176104537588669314984789719568289.00000000001', 100, '75176431543034642899535752017.0000000000000000000000000000000000000000665102066880862389165664807210932292603578885642216611023869'],
1656
+
1657
+ ['17', 60, '4.123105625617660549821409855974077025147199225373620434398633'],
1658
+ ['17', 61, '4.1231056256176605498214098559740770251471992253736204343986335'],
1659
+ ['17', 62, '4.12310562561766054982140985597407702514719922537362043439863357'],
1660
+ ['17', 63, '4.123105625617660549821409855974077025147199225373620434398633573'],
1661
+ ['17', 64, '4.1231056256176605498214098559740770251471992253736204343986335730'],
1662
+ ['17', 65, '4.12310562561766054982140985597407702514719922537362043439863357309'],
1663
+ ['17', 66, '4.123105625617660549821409855974077025147199225373620434398633573094'],
1664
+ ['17', 67, '4.1231056256176605498214098559740770251471992253736204343986335730949'],
1665
+ ['17', 68, '4.12310562561766054982140985597407702514719922537362043439863357309495'],
1666
+ ['17', 69, '4.123105625617660549821409855974077025147199225373620434398633573094954'],
1667
+ ['17', 70, '4.1231056256176605498214098559740770251471992253736204343986335730949543'],
1668
+
1669
+ ['0.0019', 0, '0'],
1670
+ ['0.0019', 1, '0.0'],
1671
+ ['0.0019', 2, '0.04'],
1672
+ ['0.0019', 3, '0.043'],
1673
+ ['0.0019', 10, '0.0435889894'],
1674
+ ['0.0019', 70, '0.0435889894354067355223698198385961565913700392523244493689034413815955'],
1675
+
1676
+ ['0.00000000015727468406479', 0, '0'],
1677
+ ['0.00000000015727468406479', 1, '0.0'],
1678
+ ['0.00000000015727468406479', 2, '0.00'],
1679
+ ['0.00000000015727468406479', 3, '0.000'],
1680
+ ['0.00000000015727468406479', 4, '0.0000'],
1681
+ ['0.00000000015727468406479', 5, '0.00001'],
1682
+ ['0.00000000015727468406479', 6, '0.000012'],
1683
+ ['0.00000000015727468406479', 7, '0.0000125'],
1684
+ ['0.00000000015727468406479', 8, '0.00001254'],
1685
+ ['0.00000000015727468406479', 9, '0.000012540'],
1686
+ ['0.00000000015727468406479', 10, '0.0000125409'],
1687
+ ['0.00000000015727468406479', 100, '0.0000125409203834802332262270521125445995500262491027973910117525063503841909945796984522050136239469'],
1688
+
1689
+ ['0.04', 0, '0'],
1690
+ ['0.04', 1, '0.2'],
1691
+ ['0.04', 2, '0.20'],
1692
+ ['0.04', 10, '0.2000000000'],
1693
+
1694
+ ['0.0004', 4, '0.0200'],
1695
+ ['0.00000000000000000000000000000004', 8, '0.00000000'],
1696
+ ['0.00000000000000000000000000000004', 16, '0.0000000000000002'],
1697
+ ['0.00000000000000000000000000000004', 32, '0.00000000000000020000000000000000'],
1698
+ ['0.000000000000000000000000000000004', 32, '0.00000000000000006324555320336758'],
1699
+
1700
+ ['111111111111111111111.11111111111111', 90, '10540925533.894597773329645148109061726360556128277733889543457102096672435043305908711407747018689086']
1701
+ ];
1702
+ }
1703
+
1704
+ public function testSqrtOfNegativeNumber() : void
1705
+ {
1706
+ $number = BigDecimal::of(-1);
1707
+ $this->expectException(NegativeNumberException::class);
1708
+ $number->sqrt(0);
1709
+ }
1710
+
1711
+ public function testSqrtWithNegativeScale() : void
1712
+ {
1713
+ $number = BigDecimal::of(1);
1714
+ $this->expectException(\InvalidArgumentException::class);
1715
+ $number->sqrt(-1);
1716
+ }
1717
+
1718
+ /**
1719
+ * @dataProvider providerPower
1720
+ *
1721
+ * @param string $number The base number.
1722
+ * @param int $exponent The exponent to apply.
1723
+ * @param string $unscaledValue The expected unscaled value of the result.
1724
+ * @param int $scale The expected scale of the result.
1725
+ */
1726
+ public function testPower(string $number, int $exponent, string $unscaledValue, int $scale) : void
1727
+ {
1728
+ self::assertBigDecimalInternalValues($unscaledValue, $scale, BigDecimal::of($number)->power($exponent));
1729
+ }
1730
+
1731
+ public function providerPower() : array
1732
+ {
1733
+ return [
1734
+ ['-3', 0, '1', 0],
1735
+ ['-2', 0, '1', 0],
1736
+ ['-1', 0, '1', 0],
1737
+ ['0', 0, '1', 0],
1738
+ ['1', 0, '1', 0],
1739
+ ['2', 0, '1', 0],
1740
+ ['3', 0, '1', 0],
1741
+
1742
+ ['-3', 1, '-3', 0],
1743
+ ['-2', 1, '-2', 0],
1744
+ ['-1', 1, '-1', 0],
1745
+ ['0', 1, '0', 0],
1746
+ ['1', 1, '1', 0],
1747
+ ['2', 1, '2', 0],
1748
+ ['3', 1, '3', 0],
1749
+
1750
+ ['-3', 2, '9', 0],
1751
+ ['-2', 2, '4', 0],
1752
+ ['-1', 2, '1', 0],
1753
+ ['0', 2, '0', 0],
1754
+ ['1', 2, '1', 0],
1755
+ ['2', 2, '4', 0],
1756
+ ['3', 2, '9', 0],
1757
+
1758
+ ['-3', 3, '-27', 0],
1759
+ ['-2', 3, '-8', 0],
1760
+ ['-1', 3, '-1', 0],
1761
+ ['0', 3, '0', 0],
1762
+ ['1', 3, '1', 0],
1763
+ ['2', 3, '8', 0],
1764
+ ['3', 3, '27', 0],
1765
+
1766
+ ['0', 1000000, '0', 0],
1767
+ ['1', 1000000, '1', 0],
1768
+
1769
+ ['-2', 255, '-57896044618658097711785492504343953926634992332820282019728792003956564819968', 0],
1770
+ [ '2', 256, '115792089237316195423570985008687907853269984665640564039457584007913129639936', 0],
1771
+
1772
+ ['-1.23', 0, '1', 0],
1773
+ ['-1.23', 0, '1', 0],
1774
+ ['-1.23', 33, '-926549609804623448265268294182900512918058893428212027689876489708283', 66],
1775
+ [ '1.23', 34, '113965602005968684136628000184496763088921243891670079405854808234118809', 68],
1776
+
1777
+ ['-123456789', 8, '53965948844821664748141453212125737955899777414752273389058576481', 0],
1778
+ ['9876543210', 7, '9167159269868350921847491739460569765344716959834325922131706410000000', 0]
1779
+ ];
1780
+ }
1781
+
1782
+ /**
1783
+ * @dataProvider providerPowerWithInvalidExponentThrowsException
1784
+ */
1785
+ public function testPowerWithInvalidExponentThrowsException(int $power) : void
1786
+ {
1787
+ $this->expectException(\InvalidArgumentException::class);
1788
+ BigDecimal::of(1)->power($power);
1789
+ }
1790
+
1791
+ public function providerPowerWithInvalidExponentThrowsException() : array
1792
+ {
1793
+ return [
1794
+ [-1],
1795
+ [1000001]
1796
+ ];
1797
+ }
1798
+
1799
+ /**
1800
+ * @dataProvider toScaleProvider
1801
+ *
1802
+ * @param string $number The number to scale.
1803
+ * @param int $toScale The scale to apply.
1804
+ * @param int $roundingMode The rounding mode to apply.
1805
+ * @param string $unscaledValue The expected unscaled value of the result.
1806
+ * @param int $scale The expected scale of the result.
1807
+ */
1808
+ public function testToScale(string $number, int $toScale, int $roundingMode, string $unscaledValue, int $scale) : void
1809
+ {
1810
+ $decimal = BigDecimal::of($number)->toScale($toScale, $roundingMode);
1811
+ self::assertBigDecimalInternalValues($unscaledValue, $scale, $decimal);
1812
+ }
1813
+
1814
+ public function toScaleProvider() : array
1815
+ {
1816
+ return [
1817
+ ['123.45', 0, RoundingMode::DOWN, '123', 0],
1818
+ ['123.45', 1, RoundingMode::UP, '1235', 1],
1819
+ ['123.45', 2, RoundingMode::UNNECESSARY, '12345', 2],
1820
+ ['123.45', 5, RoundingMode::UNNECESSARY, '12345000', 5]
1821
+ ];
1822
+ }
1823
+
1824
+ /**
1825
+ * @dataProvider providerWithPointMovedLeft
1826
+ *
1827
+ * @param string $number The decimal number as a string.
1828
+ * @param int $places The number of decimal places to move left.
1829
+ * @param string $expected The expected result.
1830
+ */
1831
+ public function testWithPointMovedLeft(string $number, int $places, string $expected) : void
1832
+ {
1833
+ self::assertBigDecimalEquals($expected, BigDecimal::of($number)->withPointMovedLeft($places));
1834
+ }
1835
+
1836
+ public function providerWithPointMovedLeft() : array
1837
+ {
1838
+ return [
1839
+ ['0', -2, '0'],
1840
+ ['0', -1, '0'],
1841
+ ['0', 0, '0'],
1842
+ ['0', 1, '0.0'],
1843
+ ['0', 2, '0.00'],
1844
+
1845
+ ['0.0', -2, '0'],
1846
+ ['0.0', -1, '0'],
1847
+ ['0.0', 0, '0.0'],
1848
+ ['0.0', 1, '0.00'],
1849
+ ['0.0', 2, '0.000'],
1850
+
1851
+ ['1', -2, '100'],
1852
+ ['1', -1, '10'],
1853
+ ['1', 0, '1'],
1854
+ ['1', 1, '0.1'],
1855
+ ['1', 2, '0.01'],
1856
+
1857
+ ['12', -2, '1200'],
1858
+ ['12', -1, '120'],
1859
+ ['12', 0, '12'],
1860
+ ['12', 1, '1.2'],
1861
+ ['12', 2, '0.12'],
1862
+
1863
+ ['1.1', -2, '110'],
1864
+ ['1.1', -1, '11'],
1865
+ ['1.1', 0, '1.1'],
1866
+ ['1.1', 1, '0.11'],
1867
+ ['1.1', 2, '0.011'],
1868
+
1869
+ ['0.1', -2, '10'],
1870
+ ['0.1', -1, '1'],
1871
+ ['0.1', 0, '0.1'],
1872
+ ['0.1', 1, '0.01'],
1873
+ ['0.1', 2, '0.001'],
1874
+
1875
+ ['0.01', -2, '1'],
1876
+ ['0.01', -1, '0.1'],
1877
+ ['0.01', 0, '0.01'],
1878
+ ['0.01', 1, '0.001'],
1879
+ ['0.01', 2, '0.0001'],
1880
+
1881
+ ['-9', -2, '-900'],
1882
+ ['-9', -1, '-90'],
1883
+ ['-9', 0, '-9'],
1884
+ ['-9', 1, '-0.9'],
1885
+ ['-9', 2, '-0.09'],
1886
+
1887
+ ['-0.9', -2, '-90'],
1888
+ ['-0.9', -1, '-9'],
1889
+ ['-0.9', 0, '-0.9'],
1890
+ ['-0.9', 1, '-0.09'],
1891
+ ['-0.9', 2, '-0.009'],
1892
+
1893
+ ['-0.09', -2, '-9'],
1894
+ ['-0.09', -1, '-0.9'],
1895
+ ['-0.09', 0, '-0.09'],
1896
+ ['-0.09', 1, '-0.009'],
1897
+ ['-0.09', 2, '-0.0009'],
1898
+
1899
+ ['-12.3', -2, '-1230'],
1900
+ ['-12.3', -1, '-123'],
1901
+ ['-12.3', 0, '-12.3'],
1902
+ ['-12.3', 1, '-1.23'],
1903
+ ['-12.3', 2, '-0.123'],
1904
+ ];
1905
+ }
1906
+
1907
+ /**
1908
+ * @dataProvider providerWithPointMovedRight
1909
+ *
1910
+ * @param string $number The decimal number as a string.
1911
+ * @param int $places The number of decimal places to move right.
1912
+ * @param string $expected The expected result.
1913
+ */
1914
+ public function testWithPointMovedRight(string $number, int $places, string $expected) : void
1915
+ {
1916
+ self::assertBigDecimalEquals($expected, BigDecimal::of($number)->withPointMovedRight($places));
1917
+ }
1918
+
1919
+ public function providerWithPointMovedRight() : array
1920
+ {
1921
+ return [
1922
+ ['0', -2, '0.00'],
1923
+ ['0', -1, '0.0'],
1924
+ ['0', 0, '0'],
1925
+ ['0', 1, '0'],
1926
+ ['0', 2, '0'],
1927
+
1928
+ ['0.0', -2, '0.000'],
1929
+ ['0.0', -1, '0.00'],
1930
+ ['0.0', 0, '0.0'],
1931
+ ['0.0', 1, '0'],
1932
+ ['0.0', 2, '0'],
1933
+
1934
+ ['9', -2, '0.09'],
1935
+ ['9', -1, '0.9'],
1936
+ ['9', 0, '9'],
1937
+ ['9', 1, '90'],
1938
+ ['9', 2, '900'],
1939
+
1940
+ ['89', -2, '0.89'],
1941
+ ['89', -1, '8.9'],
1942
+ ['89', 0, '89'],
1943
+ ['89', 1, '890'],
1944
+ ['89', 2, '8900'],
1945
+
1946
+ ['8.9', -2, '0.089'],
1947
+ ['8.9', -1, '0.89'],
1948
+ ['8.9', 0, '8.9'],
1949
+ ['8.9', 1, '89'],
1950
+ ['8.9', 2, '890'],
1951
+
1952
+ ['0.9', -2, '0.009'],
1953
+ ['0.9', -1, '0.09'],
1954
+ ['0.9', 0, '0.9'],
1955
+ ['0.9', 1, '9'],
1956
+ ['0.9', 2, '90'],
1957
+
1958
+ ['0.09', -2, '0.0009'],
1959
+ ['0.09', -1, '0.009'],
1960
+ ['0.09', 0, '0.09'],
1961
+ ['0.09', 1, '0.9'],
1962
+ ['0.09', 2, '9'],
1963
+
1964
+ ['-1', -2, '-0.01'],
1965
+ ['-1', -1, '-0.1'],
1966
+ ['-1', 0, '-1'],
1967
+ ['-1', 1, '-10'],
1968
+ ['-1', 2, '-100'],
1969
+
1970
+ ['-0.1', -2, '-0.001'],
1971
+ ['-0.1', -1, '-0.01'],
1972
+ ['-0.1', 0, '-0.1'],
1973
+ ['-0.1', 1, '-1'],
1974
+ ['-0.1', 2, '-10'],
1975
+
1976
+ ['-0.01', -2, '-0.0001'],
1977
+ ['-0.01', -1, '-0.001'],
1978
+ ['-0.01', 0, '-0.01'],
1979
+ ['-0.01', 1, '-0.1'],
1980
+ ['-0.01', 2, '-1'],
1981
+
1982
+ ['-12.3', -2, '-0.123'],
1983
+ ['-12.3', -1, '-1.23'],
1984
+ ['-12.3', 0, '-12.3'],
1985
+ ['-12.3', 1, '-123'],
1986
+ ['-12.3', 2, '-1230'],
1987
+ ];
1988
+ }
1989
+
1990
+ /**
1991
+ * @dataProvider providerStripTrailingZeros
1992
+ *
1993
+ * @param string $number The number to trim.
1994
+ * @param string $expected The expected result.
1995
+ */
1996
+ public function testStripTrailingZeros(string $number, string $expected) : void
1997
+ {
1998
+ self::assertBigDecimalEquals($expected, BigDecimal::of($number)->stripTrailingZeros());
1999
+ }
2000
+
2001
+ public function providerStripTrailingZeros() : array
2002
+ {
2003
+ return [
2004
+ ['0', '0'],
2005
+ ['0.0', '0'],
2006
+ ['0.00', '0'],
2007
+ ['0.000', '0'],
2008
+ ['0.1', '0.1'],
2009
+ ['0.01', '0.01'],
2010
+ ['0.001', '0.001'],
2011
+ ['0.100', '0.1'],
2012
+ ['0.0100', '0.01'],
2013
+ ['0.00100', '0.001'],
2014
+ ['1', '1'],
2015
+ ['1.0', '1'],
2016
+ ['1.00', '1'],
2017
+ ['1.10', '1.1'],
2018
+ ['1.123000', '1.123'],
2019
+ ['10', '10'],
2020
+ ['10.0', '10'],
2021
+ ['10.00', '10'],
2022
+ ['10.10', '10.1'],
2023
+ ['10.01', '10.01'],
2024
+ ['10.010', '10.01'],
2025
+ ['100', '100'],
2026
+ ['100.0', '100'],
2027
+ ['100.00', '100'],
2028
+ ['100.01', '100.01'],
2029
+ ['100.10', '100.1'],
2030
+ ['100.010', '100.01'],
2031
+ ['100.100', '100.1'],
2032
+ ];
2033
+ }
2034
+
2035
+ /**
2036
+ * @dataProvider providerAbs
2037
+ *
2038
+ * @param string $number The number as a string.
2039
+ * @param string $unscaledValue The expected unscaled value of the absolute result.
2040
+ * @param int $scale The expected scale of the absolute result.
2041
+ */
2042
+ public function testAbs(string $number, string $unscaledValue, int $scale) : void
2043
+ {
2044
+ self::assertBigDecimalInternalValues($unscaledValue, $scale, BigDecimal::of($number)->abs());
2045
+ }
2046
+
2047
+ public function providerAbs() : array
2048
+ {
2049
+ return [
2050
+ ['123', '123', 0],
2051
+ ['-123', '123', 0],
2052
+ ['123.456', '123456', 3],
2053
+ ['-123.456', '123456', 3]
2054
+ ];
2055
+ }
2056
+
2057
+ /**
2058
+ * @dataProvider providerNegated
2059
+ *
2060
+ * @param string $number The number to negate as a string.
2061
+ * @param string $unscaledValue The expected unscaled value of the result.
2062
+ * @param int $scale The expected scale of the result.
2063
+ */
2064
+ public function testNegated(string $number, string $unscaledValue, int $scale) : void
2065
+ {
2066
+ self::assertBigDecimalInternalValues($unscaledValue, $scale, BigDecimal::of($number)->negated());
2067
+ }
2068
+
2069
+ public function providerNegated() : array
2070
+ {
2071
+ return [
2072
+ ['123', '-123', 0],
2073
+ ['-123', '123', 0],
2074
+ ['123.456', '-123456', 3],
2075
+ ['-123.456', '123456', 3]
2076
+ ];
2077
+ }
2078
+
2079
+ /**
2080
+ * @dataProvider providerCompareTo
2081
+ *
2082
+ * @param string $a The base number as a string.
2083
+ * @param string|int|float $b The number to compare to.
2084
+ * @param int $c The comparison result.
2085
+ */
2086
+ public function testCompareTo(string $a, $b, int $c) : void
2087
+ {
2088
+ self::assertSame($c, BigDecimal::of($a)->compareTo($b));
2089
+ }
2090
+
2091
+ /**
2092
+ * @dataProvider providerCompareTo
2093
+ *
2094
+ * @param string $a The base number as a string.
2095
+ * @param string|int|float $b The number to compare to.
2096
+ * @param int $c The comparison result.
2097
+ */
2098
+ public function testIsEqualTo(string $a, $b, int $c) : void
2099
+ {
2100
+ self::assertSame($c === 0, BigDecimal::of($a)->isEqualTo($b));
2101
+ }
2102
+
2103
+ /**
2104
+ * @dataProvider providerCompareTo
2105
+ *
2106
+ * @param string $a The base number as a string.
2107
+ * @param string|int|float $b The number to compare to.
2108
+ * @param int $c The comparison result.
2109
+ */
2110
+ public function testIsLessThan(string $a, $b, int $c) : void
2111
+ {
2112
+ self::assertSame($c < 0, BigDecimal::of($a)->isLessThan($b));
2113
+ }
2114
+
2115
+ /**
2116
+ * @dataProvider providerCompareTo
2117
+ *
2118
+ * @param string $a The base number as a string.
2119
+ * @param string|int|float $b The number to compare to.
2120
+ * @param int $c The comparison result.
2121
+ */
2122
+ public function testIsLessThanOrEqualTo(string $a, $b, int $c) : void
2123
+ {
2124
+ self::assertSame($c <= 0, BigDecimal::of($a)->isLessThanOrEqualTo($b));
2125
+ }
2126
+
2127
+ /**
2128
+ * @dataProvider providerCompareTo
2129
+ *
2130
+ * @param string $a The base number as a string.
2131
+ * @param string|int|float $b The number to compare to.
2132
+ * @param int $c The comparison result.
2133
+ */
2134
+ public function testIsGreaterThan(string $a, $b, int $c) : void
2135
+ {
2136
+ self::assertSame($c > 0, BigDecimal::of($a)->isGreaterThan($b));
2137
+ }
2138
+
2139
+ /**
2140
+ * @dataProvider providerCompareTo
2141
+ *
2142
+ * @param string $a The base number as a string.
2143
+ * @param string|int|float $b The number to compare to.
2144
+ * @param int $c The comparison result.
2145
+ */
2146
+ public function testIsGreaterThanOrEqualTo(string $a, $b, int $c) : void
2147
+ {
2148
+ self::assertSame($c >= 0, BigDecimal::of($a)->isGreaterThanOrEqualTo($b));
2149
+ }
2150
+
2151
+ public function providerCompareTo() : array
2152
+ {
2153
+ return [
2154
+ ['123', '123', 0],
2155
+ ['123', '456', -1],
2156
+ ['456', '123', 1],
2157
+ ['456', '456', 0],
2158
+
2159
+ ['-123', '-123', 0],
2160
+ ['-123', '456', -1],
2161
+ [ '456', '-123', 1],
2162
+ [ '456', '456', 0],
2163
+
2164
+ [ '123', '123', 0],
2165
+ [ '123', '-456', 1],
2166
+ ['-456', '123', -1],
2167
+ ['-456', '456', -1],
2168
+
2169
+ ['-123', '-123', 0],
2170
+ ['-123', '-456', 1],
2171
+ ['-456', '-123', -1],
2172
+ ['-456', '-456', 0],
2173
+
2174
+ ['123.000000000000000000000000000000000000000000000', '123', 0],
2175
+ ['123.000000000000000000000000000000000000000000001', '123', 1],
2176
+ ['122.999999999999999999999999999999999999999999999', '123', -1],
2177
+
2178
+ ['123.0', '123.000000000000000000000000000000000000000000000', 0],
2179
+ ['123.0', '123.000000000000000000000000000000000000000000001', -1],
2180
+ ['123.0', '122.999999999999999999999999999999999999999999999', 1],
2181
+
2182
+ ['-0.000000000000000000000000000000000000000000000000001', '0', -1],
2183
+ [ '0.000000000000000000000000000000000000000000000000001', '0', 1],
2184
+ [ '0.000000000000000000000000000000000000000000000000000', '0', 0],
2185
+
2186
+ ['0', '-0.000000000000000000000000000000000000000000000000001', 1],
2187
+ ['0', '0.000000000000000000000000000000000000000000000000001', -1],
2188
+ ['0', '0.000000000000000000000000000000000000000000000000000', 0],
2189
+
2190
+ ['123.9999999999999999999999999999999999999', 124, -1],
2191
+ ['124.0000000000000000000000000000000000000', '124', 0],
2192
+ ['124.0000000000000000000000000000000000001', 124.0, 1],
2193
+
2194
+ ['123.9999999999999999999999999999999999999', '1508517100733469660019804/12165460489786045645321', -1],
2195
+ ['124.0000000000000000000000000000000000000', '1508517100733469660019804/12165460489786045645321', 0],
2196
+ ['124.0000000000000000000000000000000000001', '1508517100733469660019804/12165460489786045645321', 1],
2197
+ ];
2198
+ }
2199
+
2200
+ /**
2201
+ * @dataProvider providerSign
2202
+ *
2203
+ * @param number|string $number The number to test.
2204
+ * @param int $sign The sign of the number.
2205
+ */
2206
+ public function testGetSign($number, int $sign) : void
2207
+ {
2208
+ self::assertSame($sign, BigDecimal::of($number)->getSign());
2209
+ }
2210
+
2211
+ /**
2212
+ * @dataProvider providerSign
2213
+ *
2214
+ * @param number|string $number The number to test.
2215
+ * @param int $sign The sign of the number.
2216
+ */
2217
+ public function testIsZero($number, int $sign) : void
2218
+ {
2219
+ self::assertSame($sign === 0, BigDecimal::of($number)->isZero());
2220
+ }
2221
+
2222
+ /**
2223
+ * @dataProvider providerSign
2224
+ *
2225
+ * @param number|string $number The number to test.
2226
+ * @param int $sign The sign of the number.
2227
+ */
2228
+ public function testIsNegative($number, int $sign) : void
2229
+ {
2230
+ self::assertSame($sign < 0, BigDecimal::of($number)->isNegative());
2231
+ }
2232
+
2233
+ /**
2234
+ * @dataProvider providerSign
2235
+ *
2236
+ * @param number|string $number The number to test.
2237
+ * @param int $sign The sign of the number.
2238
+ */
2239
+ public function testIsNegativeOrZero($number, int $sign) : void
2240
+ {
2241
+ self::assertSame($sign <= 0, BigDecimal::of($number)->isNegativeOrZero());
2242
+ }
2243
+
2244
+ /**
2245
+ * @dataProvider providerSign
2246
+ *
2247
+ * @param number|string $number The number to test.
2248
+ * @param int $sign The sign of the number.
2249
+ */
2250
+ public function testIsPositive($number, int $sign) : void
2251
+ {
2252
+ self::assertSame($sign > 0, BigDecimal::of($number)->isPositive());
2253
+ }
2254
+
2255
+ /**
2256
+ * @dataProvider providerSign
2257
+ *
2258
+ * @param number|string $number The number to test.
2259
+ * @param int $sign The sign of the number.
2260
+ */
2261
+ public function testIsPositiveOrZero($number, int $sign) : void
2262
+ {
2263
+ self::assertSame($sign >= 0, BigDecimal::of($number)->isPositiveOrZero());
2264
+ }
2265
+
2266
+ public function providerSign() : array
2267
+ {
2268
+ return [
2269
+ [ 0, 0],
2270
+ [-0, 0],
2271
+ [ 1, 1],
2272
+ [-1, -1],
2273
+
2274
+ [PHP_INT_MAX, 1],
2275
+ [PHP_INT_MIN, -1],
2276
+
2277
+ [ 1.0, 1],
2278
+ [-1.0, -1],
2279
+ [ 0.1, 1],
2280
+ [-0.1, -1],
2281
+ [ 0.0, 0],
2282
+ [-0.0, 0],
2283
+
2284
+ [ '1.00', 1],
2285
+ ['-1.00', -1],
2286
+ [ '0.10', 1],
2287
+ ['-0.10', -1],
2288
+ [ '0.01', 1],
2289
+ ['-0.01', -1],
2290
+ [ '0.00', 0],
2291
+ ['-0.00', 0],
2292
+
2293
+ [ '0.000000000000000000000000000000000000000000000000000000000000000000000000000001', 1],
2294
+ [ '0.000000000000000000000000000000000000000000000000000000000000000000000000000000', 0],
2295
+ ['-0.000000000000000000000000000000000000000000000000000000000000000000000000000001', -1]
2296
+ ];
2297
+ }
2298
+
2299
+ /**
2300
+ * @dataProvider providerGetIntegralPart
2301
+ *
2302
+ * @param string $number The number to test.
2303
+ * @param string $expected The expected integral value.
2304
+ */
2305
+ public function testGetIntegralPart(string $number, string $expected) : void
2306
+ {
2307
+ self::assertSame($expected, BigDecimal::of($number)->getIntegralPart());
2308
+ }
2309
+
2310
+ public function providerGetIntegralPart() : array
2311
+ {
2312
+ return [
2313
+ ['1.23', '1'],
2314
+ ['-1.23', '-1'],
2315
+ ['0.123', '0'],
2316
+ ['0.001', '0'],
2317
+ ['123.0', '123'],
2318
+ ['12', '12'],
2319
+ ['1234.5678', '1234']
2320
+ ];
2321
+ }
2322
+
2323
+ /**
2324
+ * @dataProvider providerGetFractionalPart
2325
+ *
2326
+ * @param string $number The number to test.
2327
+ * @param string $expected The expected fractional value.
2328
+ */
2329
+ public function testGetFractionalPart(string $number, string $expected) : void
2330
+ {
2331
+ self::assertSame($expected, BigDecimal::of($number)->getFractionalPart());
2332
+ }
2333
+
2334
+ public function providerGetFractionalPart() : array
2335
+ {
2336
+ return [
2337
+ ['1.23', '23'],
2338
+ ['-1.23', '23'],
2339
+ ['1', ''],
2340
+ ['-1', ''],
2341
+ ['0', ''],
2342
+ ['0.001', '001']
2343
+ ];
2344
+ }
2345
+
2346
+ /**
2347
+ * @dataProvider providerHasNonZeroFractionalPart
2348
+ *
2349
+ * @param string $number The number to test.
2350
+ * @param bool $hasNonZeroFractionalPart The expected return value.
2351
+ */
2352
+ public function testHasNonZeroFractionalPart(string $number, bool $hasNonZeroFractionalPart) : void
2353
+ {
2354
+ self::assertSame($hasNonZeroFractionalPart, BigDecimal::of($number)->hasNonZeroFractionalPart());
2355
+ }
2356
+
2357
+ public function providerHasNonZeroFractionalPart() : array
2358
+ {
2359
+ return [
2360
+ ['1', false],
2361
+ ['1.0', false],
2362
+ ['1.01', true],
2363
+ ['-123456789', false],
2364
+ ['-123456789.0000000000000000000000000000000000000000000000000000000', false],
2365
+ ['-123456789.00000000000000000000000000000000000000000000000000000001', true]
2366
+ ];
2367
+ }
2368
+
2369
+ /**
2370
+ * @dataProvider providerToBigInteger
2371
+ *
2372
+ * @param string $decimal The number to convert.
2373
+ * @param string $expected The expected value.
2374
+ */
2375
+ public function testToBigInteger(string $decimal, string $expected) : void
2376
+ {
2377
+ self::assertBigIntegerEquals($expected, BigDecimal::of($decimal)->toBigInteger());
2378
+ }
2379
+
2380
+ public function providerToBigInteger() : array
2381
+ {
2382
+ return [
2383
+ ['0', '0'],
2384
+ ['1', '1'],
2385
+ ['0.0', '0'],
2386
+ ['1.0', '1'],
2387
+ ['-45646540654984984654165151654557478978940.0000000000000', '-45646540654984984654165151654557478978940'],
2388
+ ];
2389
+ }
2390
+
2391
+ /**
2392
+ * @dataProvider providerToBigIntegerThrowsExceptionWhenRoundingNecessary
2393
+ *
2394
+ * @param string $decimal A decimal number with a non-zero fractional part.
2395
+ */
2396
+ public function testToBigIntegerThrowsExceptionWhenRoundingNecessary(string $decimal) : void
2397
+ {
2398
+ $this->expectException(RoundingNecessaryException::class);
2399
+ BigDecimal::of($decimal)->toBigInteger();
2400
+ }
2401
+
2402
+ public function providerToBigIntegerThrowsExceptionWhenRoundingNecessary() : array
2403
+ {
2404
+ return [
2405
+ ['0.1'],
2406
+ ['-0.1'],
2407
+ ['0.01'],
2408
+ ['-0.01'],
2409
+ [ '1.002'],
2410
+ [ '0.001'],
2411
+ ['-1.002'],
2412
+ ['-0.001'],
2413
+ ['-45646540654984984654165151654557478978940.0000000000001'],
2414
+ ];
2415
+ }
2416
+
2417
+ /**
2418
+ * @dataProvider providerToBigRational
2419
+ *
2420
+ * @param string $decimal The decimal number to test.
2421
+ * @param string $rational The expected rational number.
2422
+ */
2423
+ public function testToBigRational(string $decimal, string $rational) : void
2424
+ {
2425
+ self::assertBigRationalEquals($rational, BigDecimal::of($decimal)->toBigRational());
2426
+ }
2427
+
2428
+ public function providerToBigRational() : array
2429
+ {
2430
+ return [
2431
+ ['0', '0'],
2432
+ ['1', '1'],
2433
+ ['-1', '-1'],
2434
+
2435
+ ['0.0', '0/10'],
2436
+ ['1.0', '10/10'],
2437
+ ['-1.0', '-10/10'],
2438
+
2439
+ ['0.00', '0/100'],
2440
+ ['1.00', '100/100'],
2441
+ ['-1.00', '-100/100'],
2442
+
2443
+ ['0.9', '9/10'],
2444
+ ['0.90', '90/100'],
2445
+ ['0.900', '900/1000'],
2446
+
2447
+ ['0.10', '10/100'],
2448
+ ['0.11', '11/100'],
2449
+ ['0.99', '99/100'],
2450
+ ['0.990', '990/1000'],
2451
+ ['0.9900', '9900/10000'],
2452
+
2453
+ ['1.01', '101/100'],
2454
+ ['-1.001', '-1001/1000'],
2455
+ ['-1.010', '-1010/1000'],
2456
+
2457
+ ['77867087546465423456465427464560454054654.4211684848', '778670875464654234564654274645604540546544211684848/10000000000']
2458
+ ];
2459
+ }
2460
+
2461
+ /**
2462
+ * @dataProvider providerToInt
2463
+ *
2464
+ * @param int $number The decimal number to test.
2465
+ */
2466
+ public function testToInt(int $number) : void
2467
+ {
2468
+ self::assertSame($number, BigDecimal::of($number)->toInt());
2469
+ self::assertSame($number, BigDecimal::of($number . '.0')->toInt());
2470
+ }
2471
+
2472
+ public function providerToInt() : array
2473
+ {
2474
+ return [
2475
+ [PHP_INT_MIN],
2476
+ [-123456789],
2477
+ [-1],
2478
+ [0],
2479
+ [1],
2480
+ [123456789],
2481
+ [PHP_INT_MAX]
2482
+ ];
2483
+ }
2484
+
2485
+ /**
2486
+ * @dataProvider providerToIntThrowsException
2487
+ *
2488
+ * @param string $number A valid decimal number that cannot safely be converted to a native integer.
2489
+ */
2490
+ public function testToIntThrowsException(string $number) : void
2491
+ {
2492
+ $this->expectException(MathException::class);
2493
+ BigDecimal::of($number)->toInt();
2494
+ }
2495
+
2496
+ public function providerToIntThrowsException() : array
2497
+ {
2498
+ return [
2499
+ ['-999999999999999999999999999999'],
2500
+ ['9999999999999999999999999999999'],
2501
+ ['1.2'],
2502
+ ['-1.2'],
2503
+ ];
2504
+ }
2505
+
2506
+ /**
2507
+ * @dataProvider providerToFloat
2508
+ *
2509
+ * @param string $value The big decimal value.
2510
+ * @param float $float The expected float value.
2511
+ */
2512
+ public function testToFloat(string $value, float $float) : void
2513
+ {
2514
+ self::assertSame($float, BigDecimal::of($value)->toFloat());
2515
+ }
2516
+
2517
+ public function providerToFloat() : array
2518
+ {
2519
+ return [
2520
+ ['0', 0.0],
2521
+ ['1.6', 1.6],
2522
+ ['-1.6', -1.6],
2523
+ ['9.999999999999999999999999999999999999999999999999999999999999', 9.999999999999999999999999999999],
2524
+ ['-9.999999999999999999999999999999999999999999999999999999999999', -9.999999999999999999999999999999],
2525
+ ['9.9e3000', INF],
2526
+ ['-9.9e3000', -INF],
2527
+ ];
2528
+ }
2529
+
2530
+ /**
2531
+ * @dataProvider providerToString
2532
+ *
2533
+ * @param string $unscaledValue The unscaled value.
2534
+ * @param int $scale The scale.
2535
+ * @param string $expected The expected string representation.
2536
+ */
2537
+ public function testToString(string $unscaledValue, int $scale, string $expected) : void
2538
+ {
2539
+ self::assertSame($expected, (string) BigDecimal::ofUnscaledValue($unscaledValue, $scale));
2540
+ }
2541
+
2542
+ public function providerToString() : array
2543
+ {
2544
+ return [
2545
+ ['0', 0, '0'],
2546
+ ['0', 1, '0.0'],
2547
+ ['1', 1, '0.1'],
2548
+ ['0', 2, '0.00'],
2549
+ ['1', 2, '0.01'],
2550
+ ['10', 2, '0.10'],
2551
+ ['11', 2, '0.11'],
2552
+ ['11', 3, '0.011'],
2553
+ ['1', 0, '1'],
2554
+ ['10', 1, '1.0'],
2555
+ ['11', 1, '1.1'],
2556
+ ['100', 2, '1.00'],
2557
+ ['101', 2, '1.01'],
2558
+ ['110', 2, '1.10'],
2559
+ ['111', 2, '1.11'],
2560
+ ['111', 3, '0.111'],
2561
+ ['111', 4, '0.0111'],
2562
+
2563
+ ['-1', 1, '-0.1'],
2564
+ ['-1', 2, '-0.01'],
2565
+ ['-10', 2, '-0.10'],
2566
+ ['-11', 2, '-0.11'],
2567
+ ['-12', 3, '-0.012'],
2568
+ ['-12', 4, '-0.0012'],
2569
+ ['-1', 0, '-1'],
2570
+ ['-10', 1, '-1.0'],
2571
+ ['-12', 1, '-1.2'],
2572
+ ['-100', 2, '-1.00'],
2573
+ ['-101', 2, '-1.01'],
2574
+ ['-120', 2, '-1.20'],
2575
+ ['-123', 2, '-1.23'],
2576
+ ['-123', 3, '-0.123'],
2577
+ ['-123', 4, '-0.0123'],
2578
+ ];
2579
+ }
2580
+
2581
+ public function testSerialize() : void
2582
+ {
2583
+ $value = '-1234567890987654321012345678909876543210123456789';
2584
+ $scale = 37;
2585
+
2586
+ $number = BigDecimal::ofUnscaledValue($value, $scale);
2587
+
2588
+ self::assertBigDecimalInternalValues($value, $scale, \unserialize(\serialize($number)));
2589
+ }
2590
+
2591
+ public function testDirectCallToUnserialize() : void
2592
+ {
2593
+ $this->expectException(\LogicException::class);
2594
+ BigDecimal::zero()->unserialize('123:0');
2595
+ }
2596
+ }