Passed
Push — master ( cb8425...ce0b78 )
by
unknown
01:40
created

OldInput   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 53
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
wmc 6
lcom 0
cbo 0
dl 0
loc 53
ccs 0
cts 17
cp 0
rs 10
c 0
b 0
f 0

4 Methods

Rating   Name   Duplication   Size   Complexity  
A all() 0 3 1
A get() 0 6 1
A clear() 0 7 2
A store() 0 7 2
1
<?php
2
3
namespace CarbonFramework\Input;
4
5
use Flash;
6
use CarbonFramework\Support\Arr;
7
8
/**
9
 * Provide a way to get values from the previous request
10
 */
11
class OldInput {
12
	/**
13
	 * Key to store the flashed data with
14
	 *
15
	 * @var string
16
	 */
17
	const FLASH_KEY = '__carbonFrameworkOldInput';
18
19
	/**
20
	 * Return all previously flashed request data
21
	 *
22
	 * @return array
23
	 */
24
	public static function all() {
25
		return Flash::peek( static::FLASH_KEY );
26
	}
27
28
	/**
29
	 * Return any previously flashed request data value
30
	 *
31
	 * @see Arr::get()
32
	 */
33
	public static function get() {
34
		$arguments = array_merge( [
35
			static::all(),
36
		], func_get_args() );
37
		return call_user_func_array( [Arr::class, 'get'], $arguments );
38
	}
39
40
	/**
41
	 * Clear previously stored input
42
	 */
43
	public static function clear() {
44
		if ( ! Flash::enabled() ) {
45
			return;
46
		}
47
48
		Flash::clear( static::FLASH_KEY );
49
	}
50
51
	/**
52
	 * Store the current input
53
	 *
54
	 * @param array $input
55
	 */
56
	public static function store( $input ) {
57
		if ( ! Flash::enabled() ) {
58
			return;
59
		}
60
61
		Flash::add( static::FLASH_KEY, $input );
62
	}
63
}
64