Eduardokum\LaravelBoleto\Util::isHeaderRetorno PHP Method

isHeaderRetorno() public static method

Valida se o header é de um arquivo retorno valido, 240 ou 400 posicoes
public static isHeaderRetorno ( $header ) : boolean
$header
return boolean
    public static function isHeaderRetorno($header)
    {
        if (!self::isCnab240($header) && !self::isCnab400($header)) {
            return false;
        }
        if (self::isCnab400($header) && substr($header, 0, 9) != '02RETORNO') {
            return false;
        }
        if (self::isCnab240($header) && substr($header, 142, 1) != '2') {
            return false;
        }
        return true;
    }

Usage Example

Beispiel #1
0
 /**
  * @param $file
  *
  * @return Retorno
  * @throws \Exception
  */
 public static function make($file)
 {
     if ($file == '') {
         throw new \Exception("file url is required.");
     } elseif (file_exists($file)) {
         $file_content = file($file);
     } elseif (is_string($file)) {
         $file_content = explode(PHP_EOL, $file);
     } else {
         throw new \Exception("Arquivo: {$file}, não existe");
     }
     if (!Util::isHeaderRetorno($file_content[0])) {
         throw new \Exception("Arquivo: {$file}, não é um arquivo de retorno");
     }
     $instancia = self::getBancoClass($file_content);
     return $instancia->processar();
 }
All Usage Examples Of Eduardokum\LaravelBoleto\Util::isHeaderRetorno