Skip to content

Commit ff2319e

Browse files
author
Anton Evers
committed
Bring cyclomatic complexity down from 10 to 6
1 parent 8b8c2fe commit ff2319e

1 file changed

Lines changed: 36 additions & 4 deletions

File tree

app/code/Magento/Checkout/Block/Checkout/AttributeMerger.php

Lines changed: 36 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -317,13 +317,13 @@ protected function getDefaultValue($attributeCode)
317317
{
318318
switch ($attributeCode) {
319319
case 'prefix':
320-
return $this->getCustomer() ? $this->getCustomer()->getPrefix() : null;
320+
return $this->getDefaultPrefix();
321321
case 'firstname':
322-
return $this->getCustomer() ? $this->getCustomer()->getFirstname() : null;
322+
return $this->getDefaultFirstname();
323323
case 'lastname':
324-
return $this->getCustomer() ? $this->getCustomer()->getLastname() : null;
324+
return $this->getDefaultLastname();
325325
case 'suffix':
326-
return $this->getCustomer() ? $this->getCustomer()->getSuffix() : null;
326+
return $this->getDefaultSuffix();
327327
case 'country_id':
328328
return $this->directoryHelper->getDefaultCountry();
329329
default:
@@ -387,4 +387,36 @@ protected function orderCountryOptions(array $countryOptions)
387387
}
388388
return array_merge($headOptions, $tailOptions);
389389
}
390+
391+
/**
392+
* @return null|string
393+
*/
394+
protected function getDefaultPrefix()
395+
{
396+
return $this->getCustomer() ? $this->getCustomer()->getPrefix() : null;
397+
}
398+
399+
/**
400+
* @return null|string
401+
*/
402+
protected function getDefaultFirstname()
403+
{
404+
return $this->getCustomer() ? $this->getCustomer()->getFirstname() : null;
405+
}
406+
407+
/**
408+
* @return null|string
409+
*/
410+
protected function getDefaultLastname()
411+
{
412+
return $this->getCustomer() ? $this->getCustomer()->getLastname() : null;
413+
}
414+
415+
/**
416+
* @return null|string
417+
*/
418+
protected function getDefaultSuffix()
419+
{
420+
return $this->getCustomer() ? $this->getCustomer()->getSuffix() : null;
421+
}
390422
}

0 commit comments

Comments
 (0)