1 | <?php |
||
17 | class WC_Payment_Token_CC extends WC_Payment_Token { |
||
18 | |||
19 | /** @protected string Token Type String. */ |
||
20 | protected $type = 'CC'; |
||
21 | |||
22 | /** |
||
23 | * Validate credit card payment tokens. |
||
24 | * |
||
25 | * These fields are required by all credit card payment tokens: |
||
26 | * expiry_month - string Expiration date (MM) for the card |
||
27 | * expiry_year - string Expiration date (YYYY) for the card |
||
28 | * last4 - string Last 4 digits of the card |
||
29 | * card_type - string Card type (visa, mastercard, etc) |
||
30 | * |
||
31 | * @since 2.6.0 |
||
32 | * @return boolean True if the passed data is valid |
||
33 | */ |
||
34 | public function validate() { |
||
65 | |||
66 | /** |
||
67 | * Get type to display to user. |
||
68 | * @return string |
||
69 | */ |
||
70 | public function get_display_name() { |
||
76 | |||
77 | /** |
||
78 | * Returns the card type (mastercard, visa, ...). |
||
79 | * @since 2.6.0 |
||
80 | * @return string Card type |
||
81 | */ |
||
82 | public function get_card_type() { |
||
85 | |||
86 | /** |
||
87 | * Set the card type (mastercard, visa, ...). |
||
88 | * @since 2.6.0 |
||
89 | * @param string $type |
||
90 | */ |
||
91 | public function set_card_type( $type ) { |
||
94 | |||
95 | /** |
||
96 | * Returns the card expiration year (YYYY). |
||
97 | * @since 2.6.0 |
||
98 | * @return string Expiration year |
||
99 | */ |
||
100 | public function get_expiry_year() { |
||
103 | |||
104 | /** |
||
105 | * Set the expiration year for the card (YYYY format). |
||
106 | * @since 2.6.0 |
||
107 | * @param string $year |
||
108 | */ |
||
109 | public function set_expiry_year( $year ) { |
||
112 | |||
113 | /** |
||
114 | * Returns the card expiration month (MM). |
||
115 | * @since 2.6.0 |
||
116 | * @return string Expiration month |
||
117 | */ |
||
118 | public function get_expiry_month() { |
||
121 | |||
122 | /** |
||
123 | * Set the expiration month for the card (MM format). |
||
124 | * @since 2.6.0 |
||
125 | * @param string $month |
||
126 | */ |
||
127 | public function set_expiry_month( $month ) { |
||
130 | |||
131 | /** |
||
132 | * Returns the last four digits. |
||
133 | * @since 2.6.0 |
||
134 | * @return string Last 4 digits |
||
135 | */ |
||
136 | public function get_last4() { |
||
139 | |||
140 | /** |
||
141 | * Set the last four digits. |
||
142 | * @since 2.6.0 |
||
143 | * @param string $last4 |
||
144 | */ |
||
145 | public function set_last4( $last4 ) { |
||
148 | |||
149 | } |
||
150 |
The PSR-1: Basic Coding Standard recommends that a file should either introduce new symbols, that is classes, functions, constants or similar, or have side effects. Side effects are anything that executes logic, like for example printing output, changing ini settings or writing to a file.
The idea behind this recommendation is that merely auto-loading a class should not change the state of an application. It also promotes a cleaner style of programming and makes your code less prone to errors, because the logic is not spread out all over the place.
To learn more about the PSR-1, please see the PHP-FIG site on the PSR-1.