Validate_Finance
[ class tree: Validate_Finance ] [ index: Validate_Finance ] [ all elements ]

Source for file Finance.php

Documentation is available at Finance.php

  1. <?php
  2. /* vim: set expandtab tabstop=4 shiftwidth=4: */
  3. // +----------------------------------------------------------------------+
  4. // | Copyright (c) 1997-2005 Stefan Neufeind                              |
  5. // +----------------------------------------------------------------------+
  6. // | This source file is subject to the New BSD license, That is bundled  |
  7. // | with this package in the file LICENSE, and is available through      |
  8. // | the world-wide-web at                                                |
  9. // | http://www.opensource.org/licenses/bsd-license.php                   |
  10. // | If you did not receive a copy of the new BSDlicense and are unable   |
  11. // | to obtain it through the world-wide-web, please send a note to       |
  12. // | pajoye@php.net so we can mail you a copy immediately.                |
  13. // +----------------------------------------------------------------------+
  14. // | Author: Tomas V.V.Cox  <cox@idecnet.com>                             |
  15. // |         Pierre-Alain Joye <pajoye@php.net>                           |
  16. // +----------------------------------------------------------------------+
  17. //
  18. /**
  19.  * Financial functions for validation and calculation
  20.  *
  21.  * @category   Validate
  22.  * @package    Validate_Finance
  23.  * @author     Stefan Neufeind <pear.neufeind@speedpartner.de>
  24.  * @copyright  2005 The PHP Group
  25.  * @license    http://www.opensource.org/licenses/bsd-license.php  new BSD
  26.  * @version    CVS: $Id: Finance.php,v 1.11 2005/11/01 13:12:30 pajoye Exp $
  27.  * @link       http://pear.php.net/package/Validate_Finance
  28.  */
  29.  
  30. /**
  31. * Requires the IBAN Finance Validate class
  32. */
  33. require_once 'Validate/Finance/IBAN.php';
  34.  
  35. /**
  36.  * Financial functions for validation and calculation
  37.  *
  38.  * This class provides methods to validate:
  39.  *  - IBAN (international bankaccount number)
  40.  *  - Euro banknote id
  41.  *
  42.  * @category   Validate
  43.  * @package    Validate_Finance
  44.  * @author     Stefan Neufeind <neufeind@speedpartner.de>
  45.  * @copyright  1997-2005 Stefan Neufeind
  46.  * @license    http://www.opensource.org/licenses/bsd-license.php  new BSD
  47.  * @version    Release: @package_version@
  48.  * @link       http://pear.php.net/package/Validate_Finance
  49.  */
  50. {
  51.     /**
  52.      * Validation of an IBAN (international bankaccount number)
  53.      *
  54.      * @param     string      $iban              IBAN to be validated
  55.      * @access    public
  56.      * @since     0.1
  57.      * @return    boolean   true if IBAN is okay
  58.      */
  59.     function iban($iban '')
  60.     {
  61.         return Validate_Finance_IBAN::validate($iban);
  62.     // end func iban
  63.  
  64.     
  65.     /**
  66.      * Validation of a Euro banknote id
  67.      *
  68.      * @param     string      $banknote              Euro banknote id to be validated
  69.      * @access    public
  70.      * @since     0.1
  71.      * @return    boolean   true if Euro banknote id is okay
  72.      */
  73.     function banknoteEuro($banknote '')
  74.     {
  75.         $euro_countrycode = array('J''K''L''M''N''P''R''S''T''U''V''W''X''Y''Z');
  76.  
  77.         if (strlen($banknote!= 12{
  78.             return false;
  79.         }
  80.         if (!in_array($banknote[0]$euro_countrycode)) {
  81.             return false;
  82.         }
  83.  
  84.         // build checksum, preparation
  85.         $banknote_replace_chars range('A''Z');
  86.         foreach (range(1035as $tempvalue{
  87.             $banknote_replace_values[strval($tempvalue);
  88.         }
  89.  
  90.         // build checksum, substitute and calc
  91.         $tempbanknote str_replace($banknote_replace_chars$banknote_replace_valuessubstr($banknote0-1));
  92.         $tempcheckvalue = 0;
  93.         for ($strcounter = 0; $strcounter strlen($tempbanknote)$strcounter++{
  94.             $tempcheckvalue += intval($tempbanknote[$strcounter]);
  95.         }
  96.         $tempcheckvalue %= 9; // modulo 9
  97.         $tempcheckvalue = 8 - $tempcheckvalue;
  98.  
  99.         return (intval($banknote[strlen($banknote)-1]== $tempcheckvalue);
  100.     // end func banknoteEuro
  101.  
  102. // end class Validate_Finance
  103. ?>

Documentation generated on Tue, 27 Mar 2007 11:00:03 -0400 by phpDocumentor 1.3.0. PEAR Logo Copyright © PHP Group 2004.