From 1a4ece96f8d16826019f56b2a6b4bb67c5550b3a Mon Sep 17 00:00:00 2001 From: Adam Daley Date: Mon, 21 Jul 2025 22:10:03 +0100 Subject: [PATCH] Update `Server_Client` to include first and last name (#2826) Closes #2825. --- src/library/Server/Client.php | 58 +++++++++++++++++++++++--- src/modules/Servicehosting/Service.php | 2 + 2 files changed, 54 insertions(+), 6 deletions(-) diff --git a/src/library/Server/Client.php b/src/library/Server/Client.php index 2867c7ec3..7b3483bc3 100644 --- a/src/library/Server/Client.php +++ b/src/library/Server/Client.php @@ -12,6 +12,8 @@ class Server_Client { private ?int $id = null; private ?string $email = null; + private ?string $first_name = 'FOSSBilling'; + private ?string $last_name = 'Client'; private ?string $full_name = 'FOSSBilling Client'; private ?string $company = 'FOSSBilling'; private ?string $www = 'www.fossbilling.org'; @@ -27,12 +29,8 @@ class Server_Client public function __call($name, $arguments) { - if (version_compare(PHP_VERSION, '5.4.0') < 0) { - $backtrace = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS); - } else { - // Get only the stack frames we need (PHP 5.4 only). - $backtrace = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS, 2); - } + $backtrace = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS, 2); + error_log(sprintf('Calling %s inaccessible method %s from %s::%d', static::class, $name, $backtrace[1]['file'], $backtrace[1]['line'])); return ''; @@ -62,6 +60,54 @@ class Server_Client return $this; } + /** + * Get the first name of the Server_Client instance. + * + * @return string|null returns the first name of the Server_Client instance + */ + public function getFirstName(): ?string + { + return $this->first_name; + } + + /** + * Set the first name of the Server_Client instance. + * + * @param string|null $firstName the first name to be set + * + * @return $this returns the current instance to allow for method chaining + */ + public function setFirstName(?string $firstName): static + { + $this->first_name = $firstName; + + return $this; + } + + /** + * Get the last name of the Server_Client instance. + * + * @return string|null returns the last name of the Server_Client instance + */ + public function getLastName(): ?string + { + return $this->last_name; + } + + /** + * Set the last name of the Server_Client instance. + * + * @param string|null $lastName the last name to be set + * + * @return $this returns the current instance to allow for method chaining + */ + public function setLastName(?string $lastName): static + { + $this->last_name = $lastName; + + return $this; + } + /** * Get the full name of the Server_Client instance. * diff --git a/src/modules/Servicehosting/Service.php b/src/modules/Servicehosting/Service.php index 972dfdb12..aed5aa8de 100644 --- a/src/modules/Servicehosting/Service.php +++ b/src/modules/Servicehosting/Service.php @@ -453,6 +453,8 @@ class Service implements InjectionAwareInterface $server_client = new \Server_Client(); $server_client ->setEmail($client->email) + ->setFirstName($client->first_name) + ->setLastName($client->last_name) ->setFullName($client->getFullName()) ->setCompany($client->company) ->setStreet($client->address_1)