Commit 1cce363c authored by Henning Leutz's avatar Henning Leutz 🥋

feat: implemented editMobile() + editFax() at Address Class

parent a64f2b94
......@@ -201,6 +201,60 @@ class Address extends QUI\QDOM
$this->setAttribute('phone', \json_encode($list));
}
/**
* @param $number
*/
public function editMobile($number)
{
$list = $this->getPhoneList();
$edited = false;
foreach ($list as $key => $entry) {
if ($entry['type'] !== 'mobile') {
continue;
}
$list[$key]['no'] = $number;
$edited = true;
}
if ($edited === false) {
$list[] = [
'type' => 'mobile',
'no' => $number
];
}
$this->setAttribute('phone', \json_encode($list));
}
/**
* @param $number
*/
public function editFax($number)
{
$list = $this->getPhoneList();
$edited = false;
foreach ($list as $key => $entry) {
if ($entry['type'] !== 'fax') {
continue;
}
$list[$key]['no'] = $number;
$edited = true;
}
if ($edited === false) {
$list[] = [
'type' => 'fax',
'no' => $number
];
}
$this->setAttribute('phone', \json_encode($list));
}
/**
* Delete the complete phone list
*/
......@@ -253,6 +307,30 @@ class Address extends QUI\QDOM
return '';
}
/**
* Return the first telephone number
*
* @return string
*/
public function getMobile()
{
$list = $this->getPhoneList();
if (empty($list)) {
return '';
}
foreach ($list as $entry) {
if ($entry['type'] !== 'mobile') {
continue;
}
return $entry['no'];
}
return '';
}
/**
* Return the first fax number
*
......@@ -591,7 +669,7 @@ class Address extends QUI\QDOM
unset($part[0]);
}
return \implode($part, '; ');
return \implode('; ', $part);
}
/**
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment