name = $name; $this->email_address = $email_address; $this->payer_id = $payer_id; $this->birthdate = $birthdate; $this->address = $address; $this->phone = $phone; $this->tax_info = $tax_info; } /** * Returns the name. * * @return PayerName */ public function name(): PayerName { return $this->name; } /** * Returns the email address. * * @return string */ public function email_address(): string { return $this->email_address; } /** * Returns the payer id. * * @return string */ public function payer_id(): string { return $this->payer_id; } /** * Returns the birth date. * * @return \DateTime|null */ public function birthdate() { return $this->birthdate; } /** * Returns the address. * * @return Address|null */ public function address() { return $this->address; } /** * Returns the phone. * * @return PhoneWithType|null */ public function phone() { return $this->phone; } /** * Returns the tax info. * * @return PayerTaxInfo|null */ public function tax_info() { return $this->tax_info; } /** * Returns the object as array. * * @return array */ public function to_array() { $payer = array( 'name' => $this->name()->to_array(), 'email_address' => $this->email_address(), ); if ( $this->address() ) { $payer['address'] = $this->address->to_array(); if ( 2 !== strlen( $this->address()->country_code() ) ) { unset( $payer['address'] ); } } if ( $this->payer_id() ) { $payer['payer_id'] = $this->payer_id(); } if ( $this->phone() ) { $payer['phone'] = $this->phone()->to_array(); } if ( $this->tax_info() ) { $payer['tax_info'] = $this->tax_info()->to_array(); } if ( $this->birthdate() ) { $payer['birth_date'] = $this->birthdate()->format( 'Y-m-d' ); } return $payer; } }