From be341e80e73c797a48346e61c1f8a81eca10053f Mon Sep 17 00:00:00 2001 From: Arthur Diniz Date: Tue, 23 Aug 2022 18:08:34 -0300 Subject: [PATCH] Adicionado mascara linha digitavel boleto --- .idea/.gitignore | 8 ++++ src/Predefined/Br/LinhaDigitavel.php | 13 ++++++ .../Mask/Predefined/Br/LinhaDigitavelTest.php | 45 +++++++++++++++++++ 3 files changed, 66 insertions(+) create mode 100644 .idea/.gitignore create mode 100644 src/Predefined/Br/LinhaDigitavel.php create mode 100644 tests/Mask/Predefined/Br/LinhaDigitavelTest.php diff --git a/.idea/.gitignore b/.idea/.gitignore new file mode 100644 index 0000000..13566b8 --- /dev/null +++ b/.idea/.gitignore @@ -0,0 +1,8 @@ +# Default ignored files +/shelf/ +/workspace.xml +# Editor-based HTTP Client requests +/httpRequests/ +# Datasource local storage ignored files +/dataSources/ +/dataSources.local.xml diff --git a/src/Predefined/Br/LinhaDigitavel.php b/src/Predefined/Br/LinhaDigitavel.php new file mode 100644 index 0000000..f348d8d --- /dev/null +++ b/src/Predefined/Br/LinhaDigitavel.php @@ -0,0 +1,13 @@ +assertContains('.', (new LinhaDigitavel)->getStringMask()); + $this->assertContains('#', (new LinhaDigitavel)->getStringMask()); + $this->assertNotContains('/', (new LinhaDigitavel)->getStringMask()); + $this->assertNotContains('\\', (new LinhaDigitavel)->getStringMask()); + $this->assertNotContains('-', (new LinhaDigitavel)->getStringMask()); + } + + public function provider() + { + return [ + ['00190000090312855701821548161179591160000002222'], + ]; + } + + /** + * @dataProvider provider + */ + public function testMaskDefault($linhaDigitavel) + { + $this->assertContains('.', (new LinhaDigitavel)->mask($linhaDigitavel)->toString()); + $this->assertTrue(strlen($linhaDigitavel) < strlen((new LinhaDigitavel)->mask($linhaDigitavel)->toString())); + } + + /** + * @dataProvider provider + */ + public function testMaskReal($linhaDigitavel) + { + $this->assertContains('.', (new LinhaDigitavel)->mask($linhaDigitavel)->toString()); + $this->assertEquals('00190.00009 03128.557018 21548.161179 5 91160000002222', (new LinhaDigitavel)->mask($linhaDigitavel)->toString()); + } +}