Passed
Push — master ( 896c66...72fd22 )
by Atanas
03:33
created

Arguments   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 24
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 24
ccs 9
cts 9
cp 1
rs 10
wmc 2
lcom 0
cbo 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A flip() 0 15 2
1
<?php
2
3
namespace WPEmerge\Helpers;
4
5
/**
6
 * A collection of tools dealing with urls
7
 */
8
class Arguments {
9
	/**
10
	 * Get a closure which will flip preceding optional arguments around.
11
	 * @example list( $argument1, $argument2 ) = Arguments::flip( $optional_arguments )( $argument1, $argument2 );
12
	 *
13
	 * @param  int      $optional_arguments
0 ignored issues
show
Bug introduced by
There is no parameter named $optional_arguments. Was it maybe removed?

This check looks for PHPDoc comments describing methods or function parameters that do not exist on the corresponding method or function.

Consider the following example. The parameter $italy is not defined by the method finale(...).

/**
 * @param array $germany
 * @param array $island
 * @param array $italy
 */
function finale($germany, $island) {
    return "2:1";
}

The most likely cause is that the parameter was removed, but the annotation was not.

Loading history...
14
	 * @return \Closure
0 ignored issues
show
Documentation introduced by
Should the return type not be array? Also, consider making the array more specific, something like array<String>, or String[].

This check compares the return type specified in the @return annotation of a function or method doc comment with the types returned by the function and raises an issue if they mismatch.

If the return type contains the type array, this check recommends the use of a more specific type like String[] or array<String>.

Loading history...
15
	 */
16 1
	public static function flip() {
17 1
		$arguments = func_get_args();
18 1
		$first_null = array_search( null, $arguments, true );
19
20 1
		if ( $first_null === false ) {
21 1
			return $arguments;
22
		}
23
24 1
		$arguments = array_values( array_merge(
25 1
			array_slice( $arguments, $first_null ),
26 1
			array_slice( $arguments, 0, $first_null )
27
		) );
28
29 1
		return $arguments;
30
	}
31
}
32