T3Salutation   A
last analyzed

Complexity

Total Complexity 8

Size/Duplication

Total Lines 45
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 17
dl 0
loc 45
rs 10
c 0
b 0
f 0
wmc 8

2 Methods

Rating   Name   Duplication   Size   Complexity  
A translate() 0 13 4
A reverse() 0 13 4
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-2025
7
 * @package MShop
8
 * @subpackage Common
9
 */
10
11
12
namespace Aimeos\Base\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\Base\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
	 * @param mixed $type Expected value type
28
	 * @return integer TYPO3 gender value or 99 if nothing matches
29
	 */
30
	public function translate( $value, $type = null )
31
	{
32
		switch( $value )
33
		{
34
			case 'mr':
35
				return 0;
36
			case 'ms':
37
				return 1;
38
			case 'company':
39
				return 10;
40
		}
41
42
		return 99;
43
	}
44
45
46
	/**
47
	 * Reverses the translation from the TYPO3 value to the MShop constant.
48
	 *
49
	 * @param string $value TYPO3 value or empty if not set
50
	 * @param mixed $type Expected value type
51
	 * @return string Address constant from \Aimeos\MShop\Common\Item\Address\Base
52
	 */
53
	public function reverse( $value, $type = null )
54
	{
55
		switch( $value )
56
		{
57
			case 0:
58
				return 'mr';
59
			case 1:
60
				return 'ms';
61
			case 10:
62
				return 'company';
63
		}
64
65
		return '';
66
	}
67
}
68