Test Failed
Push — main ( 28b955...362ef3 )
by Reüel
14:17 queued 10s
created

DataHelper   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 23
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
dl 0
loc 23
ccs 4
cts 4
cp 1
rs 10
c 0
b 0
f 0
wmc 1
lcom 0
cbo 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A sanitize_an() 0 14 1
1
<?php
2
/**
3
 * Data helper
4
 *
5
 * @author    Pronamic <[email protected]>
6
 * @copyright 2005-2021 Pronamic
7
 * @license   GPL-3.0-or-later
8
 * @package   Pronamic\WordPress\Pay\Gateways\Payvision
9
 */
10
11
namespace Pronamic\WordPress\Pay\Gateways\Payvision;
12
13
/**
14
 * Data helper
15
 *
16
 * @link    https://github.com/wp-pay-gateways/ideal-basic/blob/2.0.0/src/DataHelper.php
17
 * @author  Reüel van der Steege
18
 * @version 1.1.0
19
 * @since   1.1.0
20
 */
21
class DataHelper {
22
	/**
23
	 * Sanitize string to the specified length.
24
	 *
25
	 * @param string $string String.
26
	 * @param int    $length Length.
27
	 * @return string
28
	 */
29 1
	public static function sanitize_an( $string, $length ) {
30
		/**
31
		 * Remove HTML tags.
32
		 *
33
		 * @link https://stackoverflow.com/questions/5732758/detect-html-tags-in-a-string
34
		 */
35
36
		// phpcs:ignore WordPress.WP.AlternativeFunctions.strip_tags_strip_tags -- We don't want the `trim` in `wp_strip_all_tags`.
37 1
		$sanitized = \strip_tags( $string );
38
39 1
		$sanitized = \mb_substr( $sanitized, 0, $length );
40
41 1
		return $sanitized;
42
	}
43
}
44