1 | <?php |
||
14 | abstract class Basic extends Extend\Utils\Loader { |
||
15 | |||
16 | protected $section = '', $loaded = false, $primary = null, $active = null; |
||
17 | |||
18 | /** |
||
19 | * Load an item data |
||
20 | * |
||
21 | * @return array|null : the data or null on failure |
||
22 | */ |
||
23 | |||
24 | protected function loadItem(string $name) { |
||
28 | |||
29 | /** |
||
30 | * Load a first item data |
||
31 | * |
||
32 | * @return array|null : the data or null on failure |
||
33 | */ |
||
34 | |||
35 | protected function loadFirst() { |
||
48 | |||
49 | /** |
||
50 | * Load a primary item data |
||
51 | * |
||
52 | * @return array|null : the data or null on failure |
||
53 | */ |
||
54 | |||
55 | protected function loadPrimary() { |
||
61 | |||
62 | /** |
||
63 | * Load an active item data |
||
64 | * |
||
65 | * @return array|null : the data or null on failure |
||
66 | */ |
||
67 | |||
68 | protected function loadActive() { |
||
74 | |||
75 | /** |
||
76 | * Constructor |
||
77 | */ |
||
78 | |||
79 | public function __construct(string $section, bool $load_all = true) { |
||
89 | |||
90 | /** |
||
91 | * Activate an item |
||
92 | * |
||
93 | * @param $save : tells to save the new value in the global settings |
||
94 | * |
||
95 | * @return bool : true on success or false on failure |
||
96 | */ |
||
97 | |||
98 | public function activate(string $name, bool $save = false) : bool { |
||
110 | |||
111 | /** |
||
112 | * Get the active section |
||
113 | */ |
||
114 | |||
115 | public function getSection() : string { |
||
119 | |||
120 | /** |
||
121 | * Get the primary item data or a specific param value |
||
122 | * |
||
123 | * @return array|mixed|false : the data array, the param value, or false if the primary item was not loaded |
||
124 | */ |
||
125 | |||
126 | public function getPrimary(string $param = null) { |
||
132 | |||
133 | /** |
||
134 | * Get the active item data or a specific param value |
||
135 | * |
||
136 | * @return array|mixed|false : the data array, the param value, or false if the active item was not loaded |
||
137 | */ |
||
138 | |||
139 | public function get(string $param = null) { |
||
145 | } |
||
146 | } |
||
147 |
If an expression can have both
false
, andnull
as possible values. It is generally a good practice to always use strict comparison to clearly distinguish between those two values.