Completed
Push — master ( 996d66...c95bf7 )
by Jeroen De
58:45
created

TrackingDataSelector::getFirstNonEmptyValue()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 4
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 4
ccs 3
cts 3
cp 1
rs 10
c 0
b 0
f 0
cc 2
eloc 3
nc 2
nop 1
crap 2
1
<?php
2
3
declare( strict_types = 1 );
4
5
namespace WMDE\Fundraising\Frontend\Infrastructure;
6
7
/**
8
 * @license GNU GPL v2+
9
 * @author Gabriel Birke < [email protected] >
10
 * @author Kai Nissen < [email protected] >
11
 */
12
class TrackingDataSelector {
13
14 149
	public static function getFirstNonEmptyValue( array $values ): string {
15 149
		$nonEmptyValues = array_filter( $values );
16 149
		return count( $nonEmptyValues ) > 0 ? array_shift( $nonEmptyValues ) : '';
17
	}
18
19 145
	public static function concatTrackingFromVarTuple( string $campaign, string $keyword ): string {
20 145
		if ( $campaign !== '' ) {
21 14
			return strtolower( implode( '/', array_filter( [ $campaign, $keyword ] ) ) );
22
		}
23
24 133
		return '';
25
	}
26
}