Skip to content

Commit

Permalink
Merge pull request #9 from jeroendesloovere/bugfix-double-spaces-in-name
Browse files Browse the repository at this point in the history
Bugfix double spaces in name when "additional" is left empty. Fixes #8
  • Loading branch information
jeroendesloovere committed Jan 22, 2015
2 parents 8402db7 + 526c7a8 commit 84a488b
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
1.1.3 (2015-01-22)
--
Bugfixes:
* Name: Double space when no "additional" field is given. Fixes #8
17 changes: 16 additions & 1 deletion src/VCard.php
Original file line number Diff line number Diff line change
Expand Up @@ -149,8 +149,23 @@ public function addName(

// is property FN set?
if (!isset($this->properties['FN']) || $this->properties['FN'] == '') {
$values = array(
$prefix,
$firstname,
$additional,
$lastname,
$suffix
);

// loop values and remove empty ones
foreach ($values as $key => $value) {
if (empty($value)) {
unset($values[$key]);
}
}

// set property
$this->setProperty('FN', trim($prefix . ' ' . $firstname . ' ' . $additional . ' ' . $lastname . ' ' . $suffix));
$this->setProperty('FN', trim(implode(' ', $values)));
}
}

Expand Down

0 comments on commit 84a488b

Please sign in to comment.