transaction) && !$subject['object']->transaction instanceof Transaction ) { throw new \InvalidArgumentException('The object is not a class \Braintree\Transaction.'); } return $subject['object']->transaction; } /** * Reads amount from subject * * @param array $subject * @return mixed */ public function readAmount(array $subject) { return Helper\SubjectReader::readAmount($subject); } /** * Reads customer id from subject * * @param array $subject * @return int */ public function readCustomerId(array $subject) { if (!isset($subject['customer_id'])) { throw new \InvalidArgumentException('The "customerId" field does not exists'); } return (int) $subject['customer_id']; } /** * Reads public hash from subject * * @param array $subject * @return string */ public function readPublicHash(array $subject) { if (empty($subject[PaymentTokenInterface::PUBLIC_HASH])) { throw new \InvalidArgumentException('The "public_hash" field does not exists'); } return $subject[PaymentTokenInterface::PUBLIC_HASH]; } /** * Reads PayPal details from transaction object * * @param Transaction $transaction * @return array */ public function readPayPal(Transaction $transaction) { if (!isset($transaction->paypal)) { throw new \InvalidArgumentException('Transaction has\'t paypal attribute'); } return $transaction->paypal; } /** * Reads store's ID, otherwise returns null. * * @param array $subject * @return int|null */ public function readStoreId(array $subject) { return !empty($subject['store_id']) ? $subject['store_id'] : null; } }