예제 #1
0
 public function testIntegerCast()
 {
     $size = '10';
     $this->options->setSize($size);
     $this->assertEquals($size, $this->options->getSize());
     $this->assertNotSame($size, $this->options->getSize());
     $this->assertSame((int) $size, $this->options->getSize());
     $padding = '50';
     $this->options->setPadding($padding);
     $this->assertEquals($padding, $this->options->getPadding());
     $this->assertNotSame($padding, $this->options->getPadding());
     $this->assertSame((int) $padding, $this->options->getPadding());
 }
예제 #2
0
 public function testGetQrCodeContent()
 {
     $qrCode = new QrCode('FooBar');
     $qrCode->setSize($this->qrCodeOptions->getSize());
     $qrCode->setPadding($this->qrCodeOptions->getPadding());
     $qrCode->setImageType($this->qrCodeOptions->getExtension());
     $this->assertEquals($qrCode->get(), $this->qrCodeService->getQrCodeContent('FooBar'));
     $qrCode = new QrCode('www.google.com');
     $qrCode->setImageType('png');
     $qrCode->setSize(500);
     $qrCode->setPadding($this->qrCodeOptions->getPadding());
     $this->assertEquals($qrCode->get(), $this->qrCodeService->getQrCodeContent('www.google.com', 'png', 500));
     $qrCode = new QrCode('http://www.alejandrocelaya.com');
     $qrCode->setImageType('png');
     $qrCode->setSize(500);
     $qrCode->setPadding(50);
     $this->assertEquals($qrCode->get(), $this->qrCodeService->getQrCodeContent('http://www.alejandrocelaya.com', 'png', 500, 50));
 }
예제 #3
0
 /**
  * Returns a QrCode content to be rendered or saved
  * If the first argument is a Params object, all the information will be tried to be fetched for it,
  * ignoring any other argument
  * @param string|Params $messageOrParams
  * @param string $extension
  * @param int $size
  * @param int $padding
  * @return mixed
  */
 public function getQrCodeContent($messageOrParams, $extension = null, $size = null, $padding = null)
 {
     if ($messageOrParams instanceof Params) {
         $extension = $messageOrParams->fromRoute('extension', $this->options->getExtension());
         $size = $messageOrParams->fromRoute('size', $this->options->getSize());
         $padding = $messageOrParams->fromRoute('padding', $this->options->getPadding());
         $messageOrParams = $messageOrParams->fromRoute('message');
     } else {
         $extension = isset($extension) ? $extension : $this->options->getExtension();
         $size = isset($size) ? $size : $this->options->getSize();
         $padding = isset($padding) ? $padding : $this->options->getPadding();
     }
     $qrCode = new QrCode($messageOrParams);
     $qrCode->setImageType($extension);
     $qrCode->setSize($size);
     $qrCode->setPadding($padding);
     return $qrCode->get();
 }