PluginProbe ʕ •ᴥ•ʔ
VikAppointments Services Booking Calendar / 1.2.21
VikAppointments Services Booking Calendar v1.2.21
1.2.21 1.2.20 trunk 1.2.17 1.2.18 1.2.19
vikappointments / site / helpers / libraries / banking / brands / diners.php
vikappointments / site / helpers / libraries / banking / brands Last commit date
amex.php 5 days ago diners.php 5 days ago discover.php 5 days ago index.html 5 days ago jcb.php 5 days ago mastercard.php 5 days ago visa.php 5 days ago
diners.php
99 lines
1 <?php
2 /**
3 * @package VikAppointments
4 * @subpackage core
5 * @author E4J s.r.l.
6 * @copyright Copyright (C) 2021 E4J s.r.l. All Rights Reserved.
7 * @license http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL
8 * @link https://vikwp.com
9 */
10
11 // No direct access
12 defined('ABSPATH') or die('No script kiddies please!');
13
14 /**
15 * This class is used to handle Diners Club credit cards.
16 *
17 * @since 1.6
18 */
19 class CCDinersClub extends CreditCard
20 {
21 /**
22 * Checks if the credit card number is valid.
23 * The card number is valid when its length is equals to 14.
24 *
25 * @return boolean True if the card number is valid.
26 *
27 * @uses getCardNumber()
28 * @uses getCardNumberDigits()
29 */
30 public function isCardNumberValid()
31 {
32 return strlen($this->getCardNumber()) == $this->getCardNumberDigits();
33 }
34
35 /**
36 * Gets the credit card number digits count.
37 *
38 * @return integer Return the digits count (14).
39 */
40 public function getCardNumberDigits()
41 {
42 return 14;
43 }
44
45 /**
46 * Formats the credit card number to be more human-readable.
47 * e.g. 3636 0000 0000 00
48 *
49 * @return string The formatted card number.
50 *
51 * @uses getCardNumber()
52 */
53 public function formatCardNumber()
54 {
55 $cc = $this->getCardNumber();
56
57 return substr($cc, 0, 4) . ' ' . substr($cc, 4, 4) . ' ' . substr($cc, 8, 4) . ' ' . substr($cc, 12, 2);
58 }
59
60 /**
61 * Gets a masked version of the credit card for privacy.
62 * e.g. 3636 **** **** **
63 * e.g. **** 0000 0000 00
64 *
65 * @return array A list containing 2 different masked versions of card number.
66 *
67 * @uses getCardNumber()
68 */
69 public function getMaskedCardNumber()
70 {
71 $cc = $this->getCardNumber();
72
73 return array(
74 substr($cc, 0, 4) . ' **** **** **',
75 '**** ' . substr($cc, 4, 4) . ' ' . substr($cc, 8, 4) . ' ' . substr($cc, 12, 2),
76 );
77 }
78
79 /**
80 * Gets the Diners Club alias.
81 *
82 * @return string The alias of the credit card brand (diners).
83 */
84 public function getBrandAlias()
85 {
86 return CreditCard::DINERS_CLUB;
87 }
88
89 /**
90 * Gets the name of the credit card brand.
91 *
92 * @return string The name of the credit card brand (Diners Club).
93 */
94 public function getBrandName()
95 {
96 return 'Diners Club';
97 }
98 }
99