| 1 | <?php |
||
| 8 | trait HasCardFields |
||
| 9 | { |
||
| 10 | /** @var string|null The property of $this->data to look up response fields by, or null if directly on $this->data */ |
||
| 11 | protected $lookupField; |
||
| 12 | |||
| 13 | public function getCardNumber() |
||
| 17 | |||
| 18 | public function getCardExpiryYear() |
||
| 23 | |||
| 24 | public function getCardExpiryMonth() |
||
| 29 | |||
| 30 | public function getCardholderName() |
||
| 34 | |||
| 35 | public function getCardType() |
||
| 43 | |||
| 44 | protected function getResponseField($key) |
||
| 52 | |||
| 53 | protected function convertExpiryDate($yymm) |
||
| 61 | } |
||
| 62 |
This check looks for methods that are used by a trait but not required by it.
To illustrate, let’s look at the following code example
The trait
Idableprovides a methodequalsIdthat in turn relies on the methodgetId(). If this method does not exist on a class mixing in this trait, the method will fail.Adding the
getId()as an abstract method to the trait will make sure it is available.