<?php

/*
 * This file was automatically generated.
 */
namespace Worldline\Vendor\OnlinePayments\Sdk\Domain;

use UnexpectedValueException;
/**
 * @package OnlinePayments\Sdk\Domain
 */
class PersonalName extends DataObject
{
    /**
     * @var string|null
     */
    public ?string $firstName = null;
    /**
     * @var string|null
     */
    public ?string $surname = null;
    /**
     * @var string|null
     */
    public ?string $title = null;
    /**
     * @return string|null
     */
    public function getFirstName() : ?string
    {
        return $this->firstName;
    }
    /**
     * @param string|null $value
     */
    public function setFirstName(?string $value) : void
    {
        $this->firstName = $value;
    }
    /**
     * @return string|null
     */
    public function getSurname() : ?string
    {
        return $this->surname;
    }
    /**
     * @param string|null $value
     */
    public function setSurname(?string $value) : void
    {
        $this->surname = $value;
    }
    /**
     * @return string|null
     */
    public function getTitle() : ?string
    {
        return $this->title;
    }
    /**
     * @param string|null $value
     */
    public function setTitle(?string $value) : void
    {
        $this->title = $value;
    }
    /**
     * @return object
     */
    public function toObject() : object
    {
        $object = parent::toObject();
        if (!\is_null($this->firstName)) {
            $object->firstName = $this->firstName;
        }
        if (!\is_null($this->surname)) {
            $object->surname = $this->surname;
        }
        if (!\is_null($this->title)) {
            $object->title = $this->title;
        }
        return $object;
    }
    /**
     * @param object $object
     * @return $this
     * @throws UnexpectedValueException
     */
    public function fromObject(object $object) : PersonalName
    {
        parent::fromObject($object);
        if (\property_exists($object, 'firstName')) {
            $this->firstName = $object->firstName;
        }
        if (\property_exists($object, 'surname')) {
            $this->surname = $object->surname;
        }
        if (\property_exists($object, 'title')) {
            $this->title = $object->title;
        }
        return $this;
    }
}
