コード例 #1
0
 /**
  * @dataProvider cnabProvider
  * @param $fileName
  */
 public function testCnab240($fileName)
 {
     $cnab = ProcessFactory::getRetorno($fileName);
     $processor = new ProcessHandler($cnab);
     $retorno = $processor->processar();
     $this->assertInstanceOf("Umbrella\\Ya\\RetornoBoleto\\Retorno", $retorno);
     $this->assertInstanceOf("Umbrella\\Ya\\RetornoBoleto\\Cnab\\Cnab240\\Header", $retorno->getHeader());
     $this->assertInstanceOf("Umbrella\\Ya\\RetornoBoleto\\Cnab\\Cnab240\\Trailer", $retorno->getTrailer());
 }
 /**
  * @dataProvider cnabProvider
  */
 public function testEvent($fileName)
 {
     $cnab400 = ProcessFactory::getRetorno($fileName);
     $processor = new ProcessHandler($cnab400);
     $self = $this;
     $count = 0;
     $processor->getDispatcher()->addListener(RetornoEvents::ON_DETAIL_REGISTER, function (OnDetailRegisterEvent $event) use($self, &$count) {
         $self->assertEquals($event->getLineNumber(), $count);
         $count++;
     });
     $retorno = $processor->processar();
     $this->assertNotNull($retorno);
 }
コード例 #3
0
 public function segmentoProvider($segmento)
 {
     $segmentos = array();
     foreach ($this->cnabProvider() as $fileName) {
         $cnab = ProcessFactory::getRetorno(current($fileName));
         $processor = new ProcessHandler($cnab);
         $retorno = $processor->processar();
         $lotes = $retorno->getLotes();
         foreach ($lotes->get(0)->getDetails() as $detail) {
             if ($detail->getSegmento() == $segmento) {
                 $segmentos[] = array($detail);
             }
         }
     }
     return $segmentos;
 }
コード例 #4
0
ファイル: index.php プロジェクト: vmartins/ya-boleto-demo
<?php

use Symfony\Component\Debug\Debug;
use Umbrella\Ya\RetornoBoleto\ProcessFactory;
use Umbrella\Ya\RetornoBoleto\ProcessHandler;
$dirname = dirname(__DIR__);
require_once $dirname . '/../vendor/autoload.php';
Debug::enable();
// Utilizamos a factory para construir o objeto correto para um determinado arquivo de retorno
$cnab = ProcessFactory::getRetorno($dirname . '/../Resources/ret/150/RCB001454508201412843.ret');
// Passamos o objeto contruido para o handler
$processor = new ProcessHandler($cnab);
// Processamos o arquivo. Isso retornará um objeto parseado com todas as propriedades do arquvio.
$retorno = $processor->processar();
$loader = new Twig_Loader_Filesystem(array($dirname . '/../Resources/views'));
$options = array('cache_dir' => '');
$twig = new Twig_Environment($loader, $options);
$twig->getExtension('core')->setNumberFormat(2, ',', '.');
echo $twig->render('retorno.html.twig', array('model' => $retorno));