Completed
Push — 2016.04 ( 690368...e61816 )
by Aimeos
04:37
created

T3Salutation::reverse()   A

Complexity

Conditions 3
Paths 3

Size

Total Lines 12
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 3
eloc 7
nc 3
nop 1
dl 0
loc 12
rs 9.4285
c 1
b 0
f 0
1
<?php
2
3
/**
4
 * @license LGPLv3, http://opensource.org/licenses/LGPL-3.0
5
 * @copyright Metaways Infosystems GmbH, 2013
6
 * @copyright Aimeos (aimeos.org), 2014
7
 * @package MShop
8
 * @subpackage Common
9
 */
10
11
12
namespace Aimeos\MW\Criteria\Plugin;
13
14
15
/**
16
 * Criteria plugin for TYPO3 salutation/gender.
17
 *
18
 * @package MW
19
 * @subpackage Common
20
 */
21
class T3Salutation implements \Aimeos\MW\Criteria\Plugin\Iface
22
{
23
	/**
24
	 * Translates the MShop value into its TYPO3 equivalent.
25
	 *
26
	 * @param string $value Address constant from \Aimeos\MShop\Common\Item\Address\Base
27
	 * @return integer TYPO3 gender value or 99 if nothing matches
28
	 */
29
	public function translate( $value )
30
	{
31
		switch( $value )
32
		{
33
			case \Aimeos\MShop\Common\Item\Address\Base::SALUTATION_MR:
34
				return 0;
35
			case \Aimeos\MShop\Common\Item\Address\Base::SALUTATION_MRS:
36
			case \Aimeos\MShop\Common\Item\Address\Base::SALUTATION_MISS:
37
				return 1;
38
		}
39
40
		return 99;
41
	}
42
43
44
	/**
45
	 * Reverses the translation from the TYPO3 value to the MShop constant.
46
	 *
47
	 * @param string $value TYPO3 value or empty if not set
48
	 * @return string Address constant from \Aimeos\MShop\Common\Item\Address\Base
49
	 */
50
	public function reverse( $value )
51
	{
52
		switch( $value )
53
		{
54
			case 0:
55
				return \Aimeos\MShop\Common\Item\Address\Base::SALUTATION_MR;
56
			case 1:
57
				return \Aimeos\MShop\Common\Item\Address\Base::SALUTATION_MRS;
58
		}
59
60
		return \Aimeos\MShop\Common\Item\Address\Base::SALUTATION_UNKNOWN;
61
	}
62
}
63