Passed
Push — master ( 6a58b9...6d010e )
by Aimeos
02:10
created

PgSQL::escape()   A

Complexity

Conditions 5
Paths 7

Size

Total Lines 13
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 7
c 1
b 0
f 0
dl 0
loc 13
rs 9.6111
cc 5
nc 7
nop 3
1
<?php
2
3
/**
4
 * @license LGPLv3, https://opensource.org/licenses/LGPL-3.0
5
 * @copyright Aimeos (aimeos.org), 2018-2023
6
 * @package Base
7
 * @subpackage Common
8
 */
9
10
11
namespace Aimeos\Base\Criteria\Expression\Compare;
12
13
14
/**
15
 * PostgreSQL implementation for comparing objects
16
 *
17
 * @package Base
18
 * @subpackage Common
19
 */
20
class PgSQL extends SQL
21
{
22
	/**
23
	 * Escapes the value so it can be inserted into a SQL statement
24
	 *
25
	 * @param string $operator Operator used for the expression
26
	 * @param string $type Type constant
27
	 * @param mixed $value Value that the variable or column should be compared to
28
	 * @return double|string|integer Escaped value
29
	 */
30
	protected function escape( string $operator, string $type, $value )
31
	{
32
		$value = $this->translateValue( $this->getName(), $value, $type );
33
34
		switch( $type )
35
		{
36
			case 'bool':
37
			case 'boolean':
38
			case \Aimeos\Base\DB\Statement\Base::PARAM_BOOL:
39
				return ( $value ? "'t'" : "'f'" ); break;
0 ignored issues
show
Unused Code introduced by
break is not strictly necessary here and could be removed.

The break statement is not necessary if it is preceded for example by a return statement:

switch ($x) {
    case 1:
        return 'foo';
        break; // This break is not necessary and can be left off.
}

If you would like to keep this construct to be consistent with other case statements, you can safely mark this issue as a false-positive.

Loading history...
40
		}
41
42
		return parent::escape( $operator, $type, $value );
43
	}
44
}
45