Base   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 21
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 5
eloc 7
c 1
b 0
f 0
dl 0
loc 21
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A sanitize() 0 12 5
1
<?php
2
3
/**
4
 * @license LGPLv3, https://opensource.org/licenses/LGPL-3.0
5
 * @copyright Aimeos (aimeos.org), 2016-2026
6
 * @package Base
7
 * @subpackage View
8
 */
9
10
11
namespace Aimeos\Base\View\Helper\Url;
12
13
14
/**
15
 * Base view helper class for building URLs
16
 *
17
 * @package Base
18
 * @subpackage View
19
 */
20
abstract class Base extends \Aimeos\Base\View\Helper\Base
21
{
22
	/**
23
	 * Replaces dangerous characters in the parameters
24
	 *
25
	 * @param array $params Associative list of key/value pairs
26
	 * @param string[] $names Replace characters in the parameters of the given names, empty for all
27
	 * @return array Associative list with encoded values
28
	 */
29
	protected function sanitize( array $params, array $names = ['f_name', 'd_name'] ) : array
30
	{
31
		foreach( $params as $key => $value )
32
		{
33
			if( is_array( $value ) ) {
34
				$params[$key] = $this->sanitize( $value, $names );
35
			} elseif( empty( $names ) || in_array( (string) $key, $names ) ) {
36
				$params[$key] = \Aimeos\Base\Str::slug( $value );
37
			}
38
		}
39
40
		return $params;
41
	}
42
}
43