From 904b4ec824057aafcab5e393dec3a8a79055cef4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20Krej=C4=8D=C3=AD=C5=99?= Date: Fri, 31 Aug 2018 09:21:47 +0200 Subject: [PATCH] add recipient name setter --- Tests/QRPlatbaTest.php | 11 +++++++++++ src/QRPlatba.php | 14 ++++++++++++++ 2 files changed, 25 insertions(+) diff --git a/Tests/QRPlatbaTest.php b/Tests/QRPlatbaTest.php index 31860db..5d7356a 100644 --- a/Tests/QRPlatbaTest.php +++ b/Tests/QRPlatbaTest.php @@ -66,4 +66,15 @@ public function testQrCodeInstante() $this->assertInstanceOf('Endroid\\QrCode\\QrCode', $qrPlatba); } + + public function testRecipientName() + { + $string = QRPlatba::create('12-3456789012/0100', '1234.56', '2016001234') + ->setRecipientName('Düakrítičs'); + + $this->assertSame( + 'SPD*1.0*ACC:CZ0301000000123456789012*AM:1234.56*CC:CZK*X-VS:2016001234*RN:Duakritics', + $string->__toString() + ); + } } diff --git a/src/QRPlatba.php b/src/QRPlatba.php index 712a684..575b9c8 100644 --- a/src/QRPlatba.php +++ b/src/QRPlatba.php @@ -219,6 +219,20 @@ public function setMessage($msg) return $this; } + /** + * Nastavení jmena příjemce. Z řetězce bude odstraněna diaktirika. + * + * @param $name + * + * @return $this + */ + public function setRecipientName($name) + { + $this->keys['RN'] = mb_substr($this->stripDiacritics($name), 0, 35); + + return $this; + } + /** * Nastavení data úhrady. *