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()
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.