![]() Server : Apache System : Linux server2.corals.io 4.18.0-348.2.1.el8_5.x86_64 #1 SMP Mon Nov 15 09:17:08 EST 2021 x86_64 User : corals ( 1002) PHP Version : 7.4.33 Disable Function : exec,passthru,shell_exec,system Directory : /home/corals/cartforge.co/app/code/StripeIntegration/Payments/Model/Customer/ |
<?php namespace StripeIntegration\Payments\Model\Customer; class NameParser { private $firstName = null; private $middleName = null; private $lastName = null; public function fromString(?string $name) { if (!is_string($name)) return $this; $name = trim($name); if (empty($name)) return $this; $name = preg_replace('!\s+!', ' ', $name); // Replace multiple spaces $nameParts = explode(' ', $name); $this->firstName = array_shift($nameParts); if (empty($this->firstName) || count($nameParts) == 0) return $this; if (count($nameParts) == 1) { $this->lastName = $nameParts[0]; } else { $this->lastName = array_pop($nameParts); $this->middleName = implode(" ", $nameParts); } return $this; } public function getFirstname() { return $this->firstName; } public function getMiddlename() { return $this->middleName; } public function getLastname() { return $this->lastName; } }