Completed
Push — master ( 5cecff...1ffb7e )
by Glynn
30s queued 12s
created
src/Registrar/Page_Enqueue_Action.php 1 patch
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -38,7 +38,7 @@  discard block
 block discarded – undo
38 38
 	/** The option group being enqueued */
39 39
 	protected ?Abstract_Group $group;
40 40
 
41
-	public function __construct( string $hook, Page $page, ?Abstract_Group $group = null ) {
41
+	public function __construct(string $hook, Page $page, ?Abstract_Group $group = null) {
42 42
 		$this->hook  = $hook;
43 43
 		$this->page  = $page;
44 44
 		$this->group = $group;
@@ -50,15 +50,15 @@  discard block
 block discarded – undo
50 50
 	 * @param string $page_hook
51 51
 	 * @return void
52 52
 	 */
53
-	public function __invoke( string $page_hook ) {
54
-		if ( $page_hook === $this->hook ) {
53
+	public function __invoke(string $page_hook) {
54
+		if ($page_hook === $this->hook) {
55 55
 
56 56
 			// Register hooks for the group if part of group
57
-			if ( null !== $this->group ) {
58
-				$this->group->enqueue( $this->group, $this->page );
57
+			if (null !== $this->group) {
58
+				$this->group->enqueue($this->group, $this->page);
59 59
 			}
60 60
 
61
-			$this->page->enqueue( $this->page );
61
+			$this->page->enqueue($this->page);
62 62
 		}
63 63
 	}
64 64
 }
Please login to merge, or discard this patch.
src/Registrar/Page_Dispatcher.php 1 patch
Spacing   +48 added lines, -48 removed lines patch added patch discarded remove patch
@@ -40,7 +40,7 @@  discard block
 block discarded – undo
40 40
 	protected View $view;
41 41
 	protected Registrar $registrar;
42 42
 
43
-	public function __construct( DI_Container $di_container, View $view, Registrar $registrar ) {
43
+	public function __construct(DI_Container $di_container, View $view, Registrar $registrar) {
44 44
 		$this->di_container = $di_container;
45 45
 		$this->view         = $view;
46 46
 		$this->registrar    = $registrar;
@@ -52,10 +52,10 @@  discard block
 block discarded – undo
52 52
 	 * @param \PinkCrab\Perique_Admin_Menu\Group\Abstract_Group $group
53 53
 	 * @return void
54 54
 	 */
55
-	public function register_group( Abstract_Group $group ): void {
55
+	public function register_group(Abstract_Group $group): void {
56 56
 
57 57
 		// If current user can not access the group, bail without attempting to register.
58
-		if ( ! current_user_can( $group->get_capability() ) ) {
58
+		if ( ! current_user_can($group->get_capability())) {
59 59
 			return;
60 60
 		}
61 61
 
@@ -63,20 +63,20 @@  discard block
 block discarded – undo
63 63
 
64 64
 			// Validate the group.
65 65
 			$validator = new Group_Validator();
66
-			if ( ! $validator->validate( $group ) ) {
67
-				throw Group_Exception::failed_validation( $validator, $group );
66
+			if ( ! $validator->validate($group)) {
67
+				throw Group_Exception::failed_validation($validator, $group);
68 68
 			}
69 69
 
70
-			$this->register_primary_page( $group );
70
+			$this->register_primary_page($group);
71 71
 
72 72
 			// Register all pages and attempt to set primary page name in menu.
73
-			foreach ( $this->get_pages( $group ) as $page ) {
74
-				$this->register_subpage( $page, $this->get_primary_page( $group )->slug(), $group );
73
+			foreach ($this->get_pages($group) as $page) {
74
+				$this->register_subpage($page, $this->get_primary_page($group)->slug(), $group);
75 75
 			}
76
-			$this->set_primary_page_details( $group );
76
+			$this->set_primary_page_details($group);
77 77
 
78
-		} catch ( \Throwable $th ) {
79
-			$this->admin_exception_notice( $group, $th );
78
+		} catch (\Throwable $th) {
79
+			$this->admin_exception_notice($group, $th);
80 80
 		}
81 81
 	}
82 82
 
@@ -87,22 +87,22 @@  discard block
 block discarded – undo
87 87
 	 * @param \Throwable $exception
88 88
 	 * @return void
89 89
 	 */
90
-	public function admin_exception_notice( $object, Throwable $exception ): void {
90
+	public function admin_exception_notice($object, Throwable $exception): void {
91 91
 		add_action(
92 92
 			'admin_notices',
93
-			function() use ( $object, $exception ) {
93
+			function() use ($object, $exception) {
94 94
 				$class   = 'notice notice-error';
95 95
 				$message = sprintf(
96 96
 					'%s <i>%s</i> generated errors while being registered. This might result in admin pages being missing or broken. <br><b>%s(%s: %s)</b>',
97
-					get_class( $object ) === Page::class ? 'Page' : 'Menu Group',
98
-					get_class( $object ),
97
+					get_class($object) === Page::class ? 'Page' : 'Menu Group',
98
+					get_class($object),
99 99
 					$exception->getMessage(),
100 100
 					$exception->getFile(),
101 101
 					$exception->getLine()
102 102
 				);
103 103
 				printf(
104 104
 					'<div class="%1$s"><p>%2$s</p></div>',
105
-					esc_attr( $class ),
105
+					esc_attr($class),
106 106
 					wp_kses(
107 107
 						$message,
108 108
 						array(
@@ -122,9 +122,9 @@  discard block
 block discarded – undo
122 122
 	 * @param \PinkCrab\Perique_Admin_Menu\Group\Abstract_Group $group
123 123
 	 * @return void
124 124
 	 */
125
-	protected function register_primary_page( Abstract_Group $group ): void {
125
+	protected function register_primary_page(Abstract_Group $group): void {
126 126
 		$this->registrar->register_primary(
127
-			$this->get_primary_page( $group ),
127
+			$this->get_primary_page($group),
128 128
 			$group
129 129
 		);
130 130
 	}
@@ -135,17 +135,17 @@  discard block
 block discarded – undo
135 135
 	 * @param \PinkCrab\Perique_Admin_Menu\Group\Abstract_Group $group
136 136
 	 * @return \PinkCrab\Perique_Admin_Menu\Page\Page
137 137
 	 */
138
-	protected function get_primary_page( Abstract_Group $group ): Page {
138
+	protected function get_primary_page(Abstract_Group $group): Page {
139 139
 		/** @var Page */
140
-		$page = $this->di_container->create( $group->get_primary_page() );
140
+		$page = $this->di_container->create($group->get_primary_page());
141 141
 
142
-		if ( ! is_object( $page ) || ! is_a( $page, Page::class ) ) {
143
-			throw Page_Exception::invalid_page_type( $page );
142
+		if ( ! is_object($page) || ! is_a($page, Page::class)) {
143
+			throw Page_Exception::invalid_page_type($page);
144 144
 		}
145 145
 
146 146
 		// Register view if requied.
147
-		if ( \method_exists( $page, 'set_view' ) ) {
148
-			$page->set_view( $this->view );
147
+		if (\method_exists($page, 'set_view')) {
148
+			$page->set_view($this->view);
149 149
 		}
150 150
 
151 151
 		return $page;
@@ -159,18 +159,18 @@  discard block
 block discarded – undo
159 159
 	 * @return array<Page>
160 160
 	 * @throws Page_Exception (Code 202)
161 161
 	 */
162
-	protected function get_pages( Abstract_Group $group ): array {
162
+	protected function get_pages(Abstract_Group $group): array {
163 163
 		return array_map(
164
-			function( string $page ): Page {
165
-				$constructed_page = $this->di_container->create( $page );
166
-				if ( ! is_object( $constructed_page ) || ! is_a( $constructed_page, Page::class ) ) {
167
-					throw Page_Exception::invalid_page_type( $constructed_page );
164
+			function(string $page): Page {
165
+				$constructed_page = $this->di_container->create($page);
166
+				if ( ! is_object($constructed_page) || ! is_a($constructed_page, Page::class)) {
167
+					throw Page_Exception::invalid_page_type($constructed_page);
168 168
 				}
169 169
 				return $constructed_page;
170 170
 			},
171 171
 			array_filter(
172 172
 				$group->get_pages(),
173
-				function( string $page ) use ( $group ) {
173
+				function(string $page) use ($group) {
174 174
 					return $page !== $group->get_primary_page();
175 175
 				}
176 176
 			)
@@ -186,22 +186,22 @@  discard block
 block discarded – undo
186 186
 	 * @phpcs:disable WordPress.WP.GlobalVariablesOverride.Prohibited
187 187
 	 * @throws Group_Exception (code 253)
188 188
 	 */
189
-	protected function set_primary_page_details( Abstract_Group $group ) {
189
+	protected function set_primary_page_details(Abstract_Group $group) {
190 190
 		global $submenu;
191 191
 
192
-		$primary = $this->get_primary_page( $group );
192
+		$primary = $this->get_primary_page($group);
193 193
 
194
-		if ( ! array_key_exists( $primary->slug(), $submenu ) ) {
194
+		if ( ! array_key_exists($primary->slug(), $submenu)) {
195 195
 			return;
196 196
 		}
197 197
 
198 198
 		$primary_page_key = array_search(
199 199
 			$primary->slug(),
200
-			\array_column( $submenu[ $primary->slug() ], 2 ),
200
+			\array_column($submenu[$primary->slug()], 2),
201 201
 			true
202 202
 		) ?: 0;
203 203
 
204
-		$submenu[ $primary->slug() ][ $primary_page_key ][0] = $primary->menu_title();
204
+		$submenu[$primary->slug()][$primary_page_key][0] = $primary->menu_title();
205 205
 	}
206 206
 
207 207
 
@@ -213,21 +213,21 @@  discard block
 block discarded – undo
213 213
 	 * @param \PinkCrab\Perique_Admin_Menu\Group\Abstract_Group|null $group
214 214
 	 * @return void
215 215
 	 */
216
-	public function register_subpage( Page $page, string $parent_slug, ?Abstract_Group $group = null ): void {
216
+	public function register_subpage(Page $page, string $parent_slug, ?Abstract_Group $group = null): void {
217 217
 		// If user cant access the page, bail before attempting to register.
218
-		if ( ! current_user_can( $page->capability() ) ) {
218
+		if ( ! current_user_can($page->capability())) {
219 219
 			return;
220 220
 		}
221 221
 
222 222
 		// Register view if required.
223
-		if ( \method_exists( $page, 'set_view' ) ) {
224
-			$page->set_view( $this->view );
223
+		if (\method_exists($page, 'set_view')) {
224
+			$page->set_view($this->view);
225 225
 		}
226 226
 
227 227
 		try {
228
-			$this->registrar->register_subpage( $page, $parent_slug, $group );
229
-		} catch ( \Throwable $th ) {
230
-			$this->admin_exception_notice( $page, $th );
228
+			$this->registrar->register_subpage($page, $parent_slug, $group);
229
+		} catch (\Throwable $th) {
230
+			$this->admin_exception_notice($page, $th);
231 231
 		}
232 232
 	}
233 233
 
@@ -237,16 +237,16 @@  discard block
 block discarded – undo
237 237
 	 * @param \PinkCrab\Perique_Admin_Menu\Page\Page $page
238 238
 	 * @return void
239 239
 	 */
240
-	public function register_single_page( Page $page ): void {
240
+	public function register_single_page(Page $page): void {
241 241
 		// Register view if required.
242
-		if ( \method_exists( $page, 'set_view' ) ) {
243
-			$page->set_view( $this->view );
242
+		if (\method_exists($page, 'set_view')) {
243
+			$page->set_view($this->view);
244 244
 		}
245 245
 
246 246
 		try {
247
-			$this->registrar->register_primary( $page, null );
248
-		} catch ( \Throwable $th ) {
249
-			$this->admin_exception_notice( $page, $th );
247
+			$this->registrar->register_primary($page, null);
248
+		} catch (\Throwable $th) {
249
+			$this->admin_exception_notice($page, $th);
250 250
 		}
251 251
 	}
252 252
 
Please login to merge, or discard this patch.
src/Registrar/Page_Load_Action.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -34,7 +34,7 @@  discard block
 block discarded – undo
34 34
 	/** The option group being enqueued  */
35 35
 	protected ?Abstract_Group $group;
36 36
 
37
-	public function __construct( Page $page, ?Abstract_Group $group = null ) {
37
+	public function __construct(Page $page, ?Abstract_Group $group = null) {
38 38
 		$this->page  = $page;
39 39
 		$this->group = $group;
40 40
 	}
@@ -46,10 +46,10 @@  discard block
 block discarded – undo
46 46
 	 */
47 47
 	public function __invoke() {
48 48
 		// Register hooks for the group if part of group
49
-		if ( null !== $this->group ) {
50
-			$this->group->load( $this->group, $this->page );
49
+		if (null !== $this->group) {
50
+			$this->group->load($this->group, $this->page);
51 51
 		}
52 52
 
53
-		$this->page->load( $this->page );
53
+		$this->page->load($this->page);
54 54
 	}
55 55
 }
Please login to merge, or discard this patch.
src/Page/Menu_Page.php 1 patch
Spacing   +13 added lines, -13 removed lines patch added patch discarded remove patch
@@ -106,7 +106,7 @@  discard block
 block discarded – undo
106 106
 	 * @param View $view  View
107 107
 	 * @return self
108 108
 	 */
109
-	public function set_view( View $view ): self {
109
+	public function set_view(View $view): self {
110 110
 		$this->view = $view;
111 111
 		return $this;
112 112
 	}
@@ -122,8 +122,8 @@  discard block
 block discarded – undo
122 122
 	 * @return string
123 123
 	 */
124 124
 	public function slug(): string {
125
-		if ( $this->page_slug === '' ) {
126
-			throw Page_Exception::undefined_property( 'page_slug', $this );
125
+		if ($this->page_slug === '') {
126
+			throw Page_Exception::undefined_property('page_slug', $this);
127 127
 		}
128 128
 		return $this->page_slug;
129 129
 	}
@@ -132,8 +132,8 @@  discard block
 block discarded – undo
132 132
 	 * @return string
133 133
 	 */
134 134
 	public function menu_title(): string {
135
-		if ( $this->menu_title === '' ) {
136
-			throw Page_Exception::undefined_property( 'menu_title', $this );
135
+		if ($this->menu_title === '') {
136
+			throw Page_Exception::undefined_property('menu_title', $this);
137 137
 		}
138 138
 		return $this->menu_title;
139 139
 	}
@@ -167,17 +167,17 @@  discard block
 block discarded – undo
167 167
 	 * @throws Page_Exception code 201 if template not defined.
168 168
 	 */
169 169
 	public function render_view(): callable {
170
-		if ( null === $this->view ) {
171
-			throw Page_Exception::view_not_set( $this );
170
+		if (null === $this->view) {
171
+			throw Page_Exception::view_not_set($this);
172 172
 		}
173 173
 
174
-		if ( '' === $this->view_template ) {
175
-			throw Page_Exception::undefined_property( 'view_template', $this );
174
+		if ('' === $this->view_template) {
175
+			throw Page_Exception::undefined_property('view_template', $this);
176 176
 		}
177 177
 
178 178
 		return function() {
179 179
 			// @phpstan-ignore-next-line, as we have already checked for null.
180
-			$this->view->render( $this->view_template, $this->view_data );
180
+			$this->view->render($this->view_template, $this->view_data);
181 181
 		};
182 182
 
183 183
 	}
@@ -189,7 +189,7 @@  discard block
 block discarded – undo
189 189
 	 * @return void
190 190
 	 * @codeCoverageIgnore This can be tested as it does nothing and is extended only
191 191
 	 */
192
-	public function enqueue( Page $page ): void {
192
+	public function enqueue(Page $page): void {
193 193
 		// Do nothing.
194 194
 		// Can be extended in any child class that extends.
195 195
 	}
@@ -201,7 +201,7 @@  discard block
 block discarded – undo
201 201
 	 * @return void
202 202
 	 * @codeCoverageIgnore This can be tested as it does nothing and is extended only
203 203
 	 */
204
-	public function load( Page $page ): void {
204
+	public function load(Page $page): void {
205 205
 		// Do nothing.
206 206
 		// Can be extended in any child class that extends.
207 207
 	}
@@ -212,7 +212,7 @@  discard block
 block discarded – undo
212 212
 	 * @param string $page_hook
213 213
 	 * @return void
214 214
 	 */
215
-	final public function set_page_hook( string $page_hook ): void {
215
+	final public function set_page_hook(string $page_hook): void {
216 216
 		$this->page_hook = $page_hook;
217 217
 	}
218 218
 
Please login to merge, or discard this patch.
src/Module/Admin_Menu.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -38,7 +38,7 @@
 block discarded – undo
38 38
 	}
39 39
 
40 40
 	## Unused methods
41
-	public function pre_register( App_Config $config, Hook_Loader $loader, DI_Container $di_container ): void {} // phpcs:ignore Generic.CodeAnalysis.UnusedFunctionParameter.FoundInImplementedInterfaceBeforeLastUsed
42
-	public function pre_boot( App_Config $config, Hook_Loader $loader, DI_Container $di_container ): void {} // phpcs:ignore Generic.CodeAnalysis.UnusedFunctionParameter.FoundInImplementedInterfaceBeforeLastUsed
43
-	public function post_register( App_Config $config, Hook_Loader $loader, DI_Container $di_container ): void {} // phpcs:ignore Generic.CodeAnalysis.UnusedFunctionParameter.FoundInImplementedInterfaceBeforeLastUsed
41
+	public function pre_register(App_Config $config, Hook_Loader $loader, DI_Container $di_container): void {} // phpcs:ignore Generic.CodeAnalysis.UnusedFunctionParameter.FoundInImplementedInterfaceBeforeLastUsed
42
+	public function pre_boot(App_Config $config, Hook_Loader $loader, DI_Container $di_container): void {} // phpcs:ignore Generic.CodeAnalysis.UnusedFunctionParameter.FoundInImplementedInterfaceBeforeLastUsed
43
+	public function post_register(App_Config $config, Hook_Loader $loader, DI_Container $di_container): void {} // phpcs:ignore Generic.CodeAnalysis.UnusedFunctionParameter.FoundInImplementedInterfaceBeforeLastUsed
44 44
 }
Please login to merge, or discard this patch.