woocommerce-paypal-payments/modules/ppcp-api-client/src/Entity/PaymentSource.php
Anton Ukhanev d4c8282518 Use Composer modules and convert modules to PSR-4
PSR-4 is much more robust and predictable. But to do this,
a source root dir must be specified for every module.
This could be done in the root file, but this is not very modular.
Instead, now every module declares its own source root by using
the amazing Composer Merge Plugin. This approach allows each module
to also declare its own dependencies. Together, these changes allow
modules to be easily extractable to separate pacakges when the need
arises, and in general improves modularity significantly.
2021-08-26 11:01:20 +02:00

82 lines
1.2 KiB
PHP

<?php
/**
* The PaymentSource object.
*
* @package WooCommerce\PayPalCommerce\ApiClient\Entity
*/
declare(strict_types=1);
namespace WooCommerce\PayPalCommerce\ApiClient\Entity;
/**
* Class PaymentSource
*/
class PaymentSource {
/**
* The card.
*
* @var PaymentSourceCard|null
*/
private $card;
/**
* The wallet.
*
* @var PaymentSourceWallet|null
*/
private $wallet;
/**
* PaymentSource constructor.
*
* @param PaymentSourceCard|null $card The card.
* @param PaymentSourceWallet|null $wallet The wallet.
*/
public function __construct(
PaymentSourceCard $card = null,
PaymentSourceWallet $wallet = null
) {
$this->card = $card;
$this->wallet = $wallet;
}
/**
* Returns the card.
*
* @return PaymentSourceCard|null
*/
public function card() {
return $this->card;
}
/**
* Returns the wallet.
*
* @return PaymentSourceWallet|null
*/
public function wallet() {
return $this->wallet;
}
/**
* Returns the array of the object.
*
* @return array
*/
public function to_array(): array {
$data = array();
if ( $this->card() ) {
$data['card'] = $this->card()->to_array();
}
if ( $this->wallet() ) {
$data['wallet'] = $this->wallet()->to_array();
}
return $data;
}
}