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

Form::by_id()

Size

Total Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
nc 1
dl 0
loc 1
ccs 0
cts 0
cp 0
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 15 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
 * The \GV\Form class.
11
 *
12
 * Houses all base Form functionality and provides a uniform
13
 *  API to various form backends via \GV\Form implementations.
14
 */
15
abstract class Form extends Source {
16
	/**
17
	 * @var int The ID for this form.
18
	 *
19
	 * @api
20
	 * @since future
21
	 */
22
	public $ID = null;
23
24
	/**
25
	 * @var mixed The backing form.
26
	 */
27
	private $form;
0 ignored issues
show
Unused Code introduced by
The property $form 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...
28
29
	/**
30
	 * Construct a \GV\Form instance by ID.
31
	 *
32
	 * @param int|string $form_id The internal form ID.
33
	 *
34
	 * @api
35
	 * @since future
36
	 * @return \GV\Form|null An instance of this form or null if not found.
37
	 */
38
	abstract public static function by_id( $form_id );
39
40
	/**
41
	 * Get all entries for this form.
42
	 *
43
	 * @api
44
	 * @since future
45
	 *
46
	 * @return \GV\Entry_Collection The \GV\Entry_Collection
47
	 */
48
	abstract public function get_entries();
49
50
	/**
51
	 * Magic shortcuts.
52
	 *
53
	 * - `entries` -> `$this->get_entries()`
54
	 */
55
	public function __get( $key ) {
56
		switch ( $key ):
57
			case 'entries':
58
				return $this->get_entries();
59
		endswitch;
60
	}
61
}
62