-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add option to send contact first and last names instead of a single s…
…tring
- Loading branch information
1 parent
b0d3e7b
commit 2f11c07
Showing
3 changed files
with
23 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,6 +9,8 @@ | |
* @author Josh Marshall <[email protected]> | ||
* | ||
* @property string $type | ||
* @property string $first_name | ||
* @property string $last_name | ||
* @property string $name | ||
* @property string $business_name | ||
* @property string[] $lines | ||
|
@@ -22,6 +24,8 @@ | |
class Address { | ||
|
||
public $type = ''; | ||
public $first_name = ''; | ||
public $last_name = ''; | ||
public $name = ''; | ||
public $business_name = ''; | ||
public $lines = []; | ||
|
@@ -41,5 +45,18 @@ public function __construct($details = []) { | |
} | ||
$this->$key = $data; | ||
} | ||
if (!$this->name) { | ||
$this->name = trim($this->first_name . ' ' . $this->last_name); | ||
} | ||
if (!$this->first_name) { | ||
$parts = explode(' ', $this->name, 2); | ||
if (count($parts) > 1) { | ||
$this->first_name = $parts[0]; | ||
$this->last_name = $parts[1]; | ||
} else { | ||
$this->first_name = $this->name; | ||
$this->last_name = $this->name; | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters