1 | <?php |
||
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() |
||
49 | */ |
||
50 | public function __construct( \GV\Field $field, $direction = self::ASC ) { |
||
54 | } |
||
55 |
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.