PageRenderTime 44ms CodeModel.GetById 20ms RepoModel.GetById 1ms app.codeStats 0ms

/library/Ecart/Collect/CreditCard.php

https://code.google.com/p/ecartcommerce/
PHP | 86 lines | 36 code | 4 blank | 46 comment | 3 complexity | ddcd55dbf2fc2e11cec3c48c4e61acb1 MD5 | raw file
Possible License(s): GPL-3.0, LGPL-2.1
  1. <?php
  2. /**
  3. * Ecart
  4. *
  5. * This file is part of Ecart.
  6. *
  7. * Ecart is free software: you can redistribute it and/or modify
  8. * it under the terms of the GNU General Public License as published by
  9. * the Free Software Foundation, either version 3 of the License, or
  10. * (at your option) any later version.
  11. *
  12. * Ecart is distributed in the hope that it will be useful,
  13. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  15. * GNU General Public License for more details.
  16. *
  17. * You should have received a copy of the GNU General Public License
  18. * along with Ecart. If not, see <http://www.gnu.org/licenses/>.
  19. *
  20. * @category Ecart
  21. * @package Ecart_Payment
  22. * @copyright Copyright 2008-2009 E-Cart LLC
  23. * @license GNU Public License V3.0
  24. */
  25. /**
  26. *
  27. * @category Ecart
  28. * @package Ecart_Payment
  29. * @subpackage Collect
  30. * @author Ecart Core Team <core@ecartcommerce.com>
  31. */
  32. class Ecart_Collect_CreditCard implements Ecart_Collect_Interface
  33. {
  34. /**
  35. * @static
  36. * @var const array
  37. */
  38. static protected $_cards = array(
  39. // 'ALL' => Zend_Validate_CreditCard::ALL,
  40. 'AMERICAN_EXPRESS' => Zend_Validate_CreditCard::AMERICAN_EXPRESS,
  41. 'UNIONPAY' => Zend_Validate_CreditCard::UNIONPAY,
  42. 'DINERS_CLUB' => Zend_Validate_CreditCard::DINERS_CLUB,
  43. 'DINERS_CLUB_US' => Zend_Validate_CreditCard::DINERS_CLUB_US,
  44. 'DISCOVER' => Zend_Validate_CreditCard::DISCOVER,
  45. 'JCB' => Zend_Validate_CreditCard::JCB,
  46. 'LASER' => Zend_Validate_CreditCard::LASER,
  47. 'MAESTRO' => Zend_Validate_CreditCard::MAESTRO,
  48. 'MASTERCARD' => Zend_Validate_CreditCard::MASTERCARD,
  49. 'SOLO' => Zend_Validate_CreditCard::SOLO,
  50. 'VISA' => Zend_Validate_CreditCard::VISA,
  51. );
  52. /**
  53. *
  54. * @static
  55. * @return array
  56. */
  57. public static function collect()
  58. {
  59. return self::$_cards;
  60. }
  61. /**
  62. *
  63. * @static
  64. * @param string $id
  65. * @return string
  66. */
  67. public static function getName($id)
  68. {
  69. if (!$id) {
  70. return '';
  71. }
  72. if (strstr($id, ",")) {
  73. $ret = array();
  74. foreach(explode(",", $id) as $key) {
  75. if (array_key_exists($key, self::$_cards))
  76. $ret[$key] = self::$_cards[$key];
  77. }
  78. return implode(", ", $ret);
  79. }
  80. return self::$_cards[$id];
  81. }
  82. }