1 | <?php |
||
12 | class View_Collection extends Collection { |
||
13 | /** |
||
14 | * Add a \GV\View to this collection. |
||
15 | * |
||
16 | * @param \GV\View $view The view to add to the internal array. |
||
17 | * |
||
18 | * @api |
||
19 | * @since 2.0 |
||
20 | * @return void |
||
21 | */ |
||
22 | 28 | public function add( $view ) { |
|
31 | |||
32 | /** |
||
33 | * Get a \GV\View from this list. |
||
34 | * |
||
35 | * @param int $view_id The ID of the view to get. |
||
36 | * |
||
37 | * @api |
||
38 | * @since 2.0 |
||
39 | * |
||
40 | * @return \GV\View|null The \GV\View with the $view_id as the ID, or null if not found. |
||
41 | */ |
||
42 | 4 | public function get( $view_id ) { |
|
50 | |||
51 | /** |
||
52 | * Check whether \GV\View with an ID is already here. |
||
53 | * |
||
54 | * @param int $view_id The ID of the view to check. |
||
55 | * |
||
56 | * @api |
||
57 | * @since 2.0 |
||
58 | * |
||
59 | * @return boolean Whether it exists or not. |
||
60 | */ |
||
61 | 4 | public function contains( $view_id ) { |
|
64 | |||
65 | /** |
||
66 | * Get a list of \GV\View objects inside the supplied \WP_Post. |
||
67 | * |
||
68 | * The post can be a gravityview post, which is the simplest case. |
||
69 | * The post can contain gravityview shortcodes as well. |
||
70 | * The post meta can contain gravityview shortcodes. |
||
71 | * |
||
72 | * @param \WP_Post $post The \WP_Post object to look into. |
||
73 | * |
||
74 | * @api |
||
75 | * @since 2.0 |
||
76 | * @return \GV\View_Collection A \GV\View_Collection instance contanining the views inside the supplied \WP_Post. |
||
77 | */ |
||
78 | 4 | public static function from_post( \WP_Post $post ) { |
|
123 | |||
124 | /** |
||
125 | * Get a list of detected \GV\View objects inside the supplied content. |
||
126 | * |
||
127 | * The content can have a shortcode, this is the simplest case. |
||
128 | * |
||
129 | * @param string $content The content to look into. |
||
130 | * |
||
131 | * @api |
||
132 | * @since 2.0 |
||
133 | * @return \GV\View_Collection A \GV\View_Collection instance containing the views inside the supplied \WP_Post. |
||
134 | */ |
||
135 | 1 | public static function from_content( $content ) { |
|
157 | } |
||
158 |
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.