<?php
/**
 * @copyright (c) Kufer Software GmbH, Loisachstrasse 4, D-84453 Mühldorf
 */

namespace KtoPruef;

/**
 * @copyright (c) Kufer Software GmbH, Loisachstrasse 4, D-84453 Mühldorf
 */
class LocalCheck implements KtoPruefInterface
{
  public function checkKto($blz, $kto)
  {
    $dbwblz = new \DBWorkBlz();
    $row = $dbwblz->getRowByBlz($blz);
    if ($row) {
      return \PruefziffAPI::checkKtoBlz($kto, $row->pruefziff, $blz);
    } else {
      return true;
    }
  }

  public function checkBLZ($blz)
  {
    $dbwblz = new \DBWorkBlz();
    $row = $dbwblz->getRowByBlz($blz);
    if ($row) {
      return true;
    } else {
      return false;
    }
  }

  public function getBank4Blz($blz)
  {
    $dbwblz = new \DBWorkBlz();
    $row = $dbwblz->getRowByBlz($blz);
    if ($row) {
      return array(
                'blz' => $row->blz,
                'ezucode' => $row->ezucode,
                'bez_lang' => $row->bez_lang,
                'bic' => $row->bic
              );
    } else {
      return false;
    }
  }

  public function checkIBAN($iban)
  {
    return \PruefziffAPI::checkIbanBic($iban);
  }

  public function checkBic($bic)
  {
    $dbwblz = new \DBWorkBlz();
    $row = $dbwblz->getRowByBic($bic);
    if ($row) {
      return true;
    } else {
      return false;
    }
  }

  public function getBank4Bic($bic)
  {
    $dbwblz = new \DBWorkBlz();
    $row = $dbwblz->getRowByBic($bic);
    if ($row) {
      return array(
                'blz' => $row->blz,
                'ezucode' => $row->ezucode,
                'bez_lang' => $row->bez_lang,
                'bic' => $row->bic
              );
    } else {
      return false;
    }
  }
}