Completed
Push — master ( af77e8...7d9d07 )
by Zack
11s
created

Entry_Sort::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
cc 1
eloc 3
nc 1
nop 2
dl 0
loc 4
ccs 0
cts 4
cp 0
crap 2
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
 * Entry sorting.
11
 */
12
class Entry_Sort {
13
14
	/**
15
	 * @var string An enum of sorts, sort direction identifier - ascending.
16
	 */
17
	const ASC = 'ASC';
18
19
	/**
20
	 * @var string An enum of sorts, sort direction identifier - descending.
21
	 */
22
	const DESC = 'DESC';
23
24
	/**
25
	 * @var string An enum of sorts, sort direction identifier - random.
26
	 */
27
	const RAND = 'RAND';
28
29
	/**
30
	 * @var \GV\Field The field that this sort is for.
31
	 */
32
	public $field;
33
34
	/**
35
	 * @var string The direction (see self::ASC, self::DESC).
36
	 */
37
	public $direction;
38
39
	/**
40
	 * Instantiate a sort for a field.
41
	 *
42
	 * @param \GV\Field $field The field we're sorting by.
43
	 * @param string $direction The direction of this sort (\GV\Entry_Sort::ASC, \GV\Entry_Sort::DESC, etc.).
44
	 *
45
	 * @api
46
	 * @since future
47
	 *
48
	 * @return \GV\Entry_Sort An instance of this class, pass to \GV\Entry_Collection::sort()
0 ignored issues
show
Comprehensibility Best Practice introduced by
Adding a @return annotation to constructors is generally not recommended as a constructor does not have a meaningful return value.

Adding a @return annotation to a constructor is not recommended, since a constructor does not have a meaningful return value.

Please refer to the PHP core documentation on constructors.

Loading history...
49
	 */
50
	public function __construct( \GV\Field $field, $direction = self::ASC ) {
51
		$this->field = $field;
52
		$this->direction = $direction;
53
	}
54
}
55