Completed
Push — develop ( 0eab66...c30d8d )
by Zack
11:05 queued 03:39
created

Context::__set()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 1

Importance

Changes 0
Metric Value
cc 1
eloc 2
nc 1
nop 2
dl 0
loc 3
ccs 3
cts 3
cp 1
crap 1
rs 10
c 0
b 0
f 0
1
<?php
0 ignored issues
show
Coding Style Compatibility introduced by
For compatibility and reusability of your code, PSR1 recommends that a file should introduce either new symbols (like classes, functions, etc.) or have side-effects (like outputting something, or including other files), but not both at the same time. The first symbol is defined on line 12 and the first side effect is on line 6.

The PSR-1: Basic Coding Standard recommends that a file should either introduce new symbols, that is classes, functions, constants or similar, or have side effects. Side effects are anything that executes logic, like for example printing output, changing ini settings or writing to a file.

The idea behind this recommendation is that merely auto-loading a class should not change the state of an application. It also promotes a cleaner style of programming and makes your code less prone to errors, because the logic is not spread out all over the place.

To learn more about the PSR-1, please see the PHP-FIG site on the PSR-1.

Loading history...
2
namespace GV;
3
4
/** If this file is called directly, abort. */
5
if ( ! defined( 'GRAVITYVIEW_DIR' ) ) {
6
	die();
7
}
8
9
/**
10
 * A generic Context base class.
11
 */
12
class Context {
13
	/**
14
	 * @var string The context identifier, used in filters.
15
	 */
16
	private $_identifier = 'generic';
0 ignored issues
show
Unused Code introduced by
The property $_identifier is not used and could be removed.

This check marks private properties in classes that are never used. Those properties can be removed.

Loading history...
17
18
	/**
19
	 * @var array Context key-value storage.
20
	 */
21
	private $_context = array();
22
23
	/**
24
	 * Set a key to a value.
25
	 *
26
	 * @param mixed $key The key the value should be added under.
27
	 * @param mixed $value The value to be added to the key.
28
	 *
29
	 * @api
30
	 * @since future
31
	 * @return void
32
	 */
33 1
	public function __set( $key, $value ) {
34 1
		$this->_context[$key] = $value;
0 ignored issues
show
introduced by
Array keys should be surrounded by spaces unless they contain a string or an integer.
Loading history...
35 1
	}
36
37
	/**
38
	 * Set an setting.
39
	 *
40
	 * @param mixed $key The key in this setting to retrieve.
41
	 * @param mixed $default A default in case the key is not set. 
0 ignored issues
show
Bug introduced by
There is no parameter named $default. 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...
42
	 *
43
	 * @api
44
	 * @since future
45
	 * @return mixed|null
46
	 */
47 1
	public function __get( $key ) {
48 1
		return isset( $this->_context[$key] ) ? $this->_context[$key] : null;
0 ignored issues
show
introduced by
Array keys should be surrounded by spaces unless they contain a string or an integer.
Loading history...
49
	}
50
}
51
52
/** Load implementations. */
53
require gravityview()->plugin->dir( 'future/includes/class-gv-context-field-value.php' );
54