Completed
Push — master ( 7b9919...5cecff )
by Glynn
21s queued 12s
created
src/Exception/Group_Exception.php 1 patch
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -38,11 +38,11 @@  discard block
 block discarded – undo
38 38
 	 * @return self
39 39
 	 * @code 250
40 40
 	 */
41
-	public static function primary_page_undefined( Abstract_Group $group ): self {
41
+	public static function primary_page_undefined(Abstract_Group $group): self {
42 42
 		return new self(
43 43
 			sprintf(
44 44
 				'The primary page is not defined in %s',
45
-				get_class( $group )
45
+				get_class($group)
46 46
 			),
47 47
 			250
48 48
 		);
@@ -55,11 +55,11 @@  discard block
 block discarded – undo
55 55
 	 * @return self
56 56
 	 * @code 251
57 57
 	 */
58
-	public static function group_title_undefined( Abstract_Group $group ): self {
58
+	public static function group_title_undefined(Abstract_Group $group): self {
59 59
 		return new self(
60 60
 			sprintf(
61 61
 				'The group title is not defined in %s',
62
-				get_class( $group )
62
+				get_class($group)
63 63
 			),
64 64
 			251
65 65
 		);
@@ -73,12 +73,12 @@  discard block
 block discarded – undo
73 73
 	 * @return self
74 74
 	 * @code 252
75 75
 	 */
76
-	public static function failed_validation( Group_Validator $validator, Abstract_Group $group ): self {
76
+	public static function failed_validation(Group_Validator $validator, Abstract_Group $group): self {
77 77
 		return new self(
78 78
 			sprintf(
79 79
 				'%s failed Group validation (%s)',
80
-				get_class( $group ),
81
-				join( ',', $validator->get_errors() )
80
+				get_class($group),
81
+				join(',', $validator->get_errors())
82 82
 			),
83 83
 			252
84 84
 		);
Please login to merge, or discard this patch.
src/Validator/Abstract_Validator.php 2 patches
Indentation   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -27,10 +27,10 @@
 block discarded – undo
27 27
 abstract class Abstract_Validator {
28 28
 
29 29
 		/**
30
-	 * Holds any errors encounted when validation a group.
31
-	 *
32
-	 * @var array<string>
33
-	 */
30
+		 * Holds any errors encounted when validation a group.
31
+		 *
32
+		 * @var array<string>
33
+		 */
34 34
 	protected $errors = array();
35 35
 
36 36
 	/**
Please login to merge, or discard this patch.
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -48,7 +48,7 @@  discard block
 block discarded – undo
48 48
 	 * @return bool
49 49
 	 */
50 50
 	public function has_errors(): bool {
51
-		return count( $this->errors ) > 0;
51
+		return count($this->errors) > 0;
52 52
 	}
53 53
 
54 54
 	/**
@@ -66,7 +66,7 @@  discard block
 block discarded – undo
66 66
 	 * @param string $error
67 67
 	 * @return void
68 68
 	 */
69
-	public function push_error( string $error ): void {
69
+	public function push_error(string $error): void {
70 70
 		$this->errors[] = $error;
71 71
 	}
72 72
 
@@ -76,5 +76,5 @@  discard block
 block discarded – undo
76 76
 	 * @param mixed $subject
77 77
 	 * @return bool
78 78
 	 */
79
-	abstract public function validate( $subject): bool;
79
+	abstract public function validate($subject): bool;
80 80
 }
Please login to merge, or discard this patch.
src/Validator/Group_Validator.php 1 patch
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -35,15 +35,15 @@  discard block
 block discarded – undo
35 35
 	 * @param mixed $group
36 36
 	 * @return bool
37 37
 	 */
38
-	public function validate( $group ): bool {
38
+	public function validate($group): bool {
39 39
 		$this->reset_errors();
40 40
 
41
-		if ( ! is_a( $group, Abstract_Group::class ) ) {
42
-			$this->push_error( sprintf( '%s Is not a valid group type.', get_class( $group ) ) );
41
+		if ( ! is_a($group, Abstract_Group::class)) {
42
+			$this->push_error(sprintf('%s Is not a valid group type.', get_class($group)));
43 43
 			return false;
44 44
 		}
45 45
 
46
-		return $this->check_properties( $group );
46
+		return $this->check_properties($group);
47 47
 	}
48 48
 
49 49
 	/**
@@ -53,12 +53,12 @@  discard block
 block discarded – undo
53 53
 	 * @param \PinkCrab\Perique_Admin_Menu\Group\Abstract_Group $group
54 54
 	 * @return bool
55 55
 	 */
56
-	protected function check_properties( Abstract_Group $group ): bool {
56
+	protected function check_properties(Abstract_Group $group): bool {
57 57
 		try {
58 58
 			$group->get_primary_page();
59 59
 			$group->get_group_title();
60
-		} catch ( \Throwable $th ) {
61
-			$this->push_error( $th->getMessage() );
60
+		} catch (\Throwable $th) {
61
+			$this->push_error($th->getMessage());
62 62
 			return false;
63 63
 		}
64 64
 		return true;
Please login to merge, or discard this patch.
src/Exception/Page_Exception.php 1 patch
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -37,11 +37,11 @@  discard block
 block discarded – undo
37 37
 	 * @return self
38 38
 	 * @code 200
39 39
 	 */
40
-	public static function view_not_set( Page $page ): self {
40
+	public static function view_not_set(Page $page): self {
41 41
 		return new self(
42 42
 			sprintf(
43 43
 				'View must be defined in %s to render template',
44
-				get_class( $page )
44
+				get_class($page)
45 45
 			),
46 46
 			200
47 47
 		);
@@ -54,12 +54,12 @@  discard block
 block discarded – undo
54 54
 	 * @return self
55 55
 	 * @code 201
56 56
 	 */
57
-	public static function undefined_property( string $property, Page $page ): self {
57
+	public static function undefined_property(string $property, Page $page): self {
58 58
 		return new self(
59 59
 			sprintf(
60 60
 				'%s is a required property, not set in %s',
61 61
 				$property,
62
-				get_class( $page )
62
+				get_class($page)
63 63
 			),
64 64
 			201
65 65
 		);
@@ -73,11 +73,11 @@  discard block
 block discarded – undo
73 73
 	 * @return self
74 74
 	 * @code 202
75 75
 	 */
76
-	public static function invalid_page_type( $page ): self {
76
+	public static function invalid_page_type($page): self {
77 77
 		return new self(
78 78
 			sprintf(
79 79
 				'%s is not defined in the Registrar and can not be registered.',
80
-				is_object( $page ) ? get_class( $page ) : 'UNKONW TYPE'
80
+				is_object($page) ? get_class($page) : 'UNKONW TYPE'
81 81
 			),
82 82
 			202
83 83
 		);
Please login to merge, or discard this patch.
src/Registration_Middleware/Page_Middleware.php 1 patch
Spacing   +14 added lines, -14 removed lines patch added patch discarded remove patch
@@ -56,42 +56,42 @@  discard block
 block discarded – undo
56 56
 	 * @param object $class
57 57
 	 * @return object
58 58
 	 */
59
-	public function process( $class ) {
59
+	public function process($class) {
60 60
 		// If we have a valid SUB page.
61 61
 		if (
62
-			is_a( $class, Page::class )
62
+			is_a($class, Page::class)
63 63
 			&& is_admin()
64
-			&& ! is_null( $class->parent_slug() )
64
+			&& ! is_null($class->parent_slug())
65 65
 		) {
66 66
 			$this->add_to_loader(
67
-				function () use ( $class ) : void {
68
-					$this->dispatcher->register_subpage( $class, $class->parent_slug() );
67
+				function() use ($class) : void {
68
+					$this->dispatcher->register_subpage($class, $class->parent_slug());
69 69
 				}
70 70
 			);
71 71
 		}
72 72
 
73 73
 		// If we have a valid SINGLE/PARENT page.
74 74
 		if (
75
-			is_a( $class, Page::class )
75
+			is_a($class, Page::class)
76 76
 			&& is_admin()
77
-			&& is_null( $class->parent_slug() )
77
+			&& is_null($class->parent_slug())
78 78
 		) {
79 79
 			$this->add_to_loader(
80
-				function () use ( $class ) : void {
81
-					$this->dispatcher->register_single_page( $class );
80
+				function() use ($class) : void {
81
+					$this->dispatcher->register_single_page($class);
82 82
 				}
83 83
 			);
84 84
 		}
85 85
 
86 86
 		// If we have a valid group.
87 87
 		if (
88
-			is_a( $class, Abstract_Group::class )
88
+			is_a($class, Abstract_Group::class)
89 89
 			&& is_admin()
90 90
 		) {
91 91
 
92 92
 			$this->add_to_loader(
93
-				function () use ( $class ): void {
94
-					$this->dispatcher->register_group( $class );
93
+				function() use ($class): void {
94
+					$this->dispatcher->register_group($class);
95 95
 				}
96 96
 			);
97 97
 		}
@@ -104,8 +104,8 @@  discard block
 block discarded – undo
104 104
 	 * @param callable $callback
105 105
 	 * @return void
106 106
 	 */
107
-	protected function add_to_loader( callable $callback ): void {
108
-		$this->hook_loader->action( 'admin_menu', $callback );
107
+	protected function add_to_loader(callable $callback): void {
108
+		$this->hook_loader->action('admin_menu', $callback);
109 109
 	}
110 110
 
111 111
 
Please login to merge, or discard this patch.
src/Registrar/Page_Enqueue_Action.php 1 patch
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -50,7 +50,7 @@  discard block
 block discarded – undo
50 50
 	 */
51 51
 	protected $group;
52 52
 
53
-	public function __construct( string $hook, Page $page, ?Abstract_Group $group = null ) {
53
+	public function __construct(string $hook, Page $page, ?Abstract_Group $group = null) {
54 54
 		$this->hook  = $hook;
55 55
 		$this->page  = $page;
56 56
 		$this->group = $group;
@@ -62,15 +62,15 @@  discard block
 block discarded – undo
62 62
 	 * @param string $page_hook
63 63
 	 * @return void
64 64
 	 */
65
-	public function __invoke( string $page_hook ) {
66
-		if ( $page_hook === $this->hook ) {
65
+	public function __invoke(string $page_hook) {
66
+		if ($page_hook === $this->hook) {
67 67
 
68 68
 			// Register hooks for the group if part of group
69
-			if ( null !== $this->group ) {
70
-				$this->group->enqueue( $this->group, $this->page );
69
+			if (null !== $this->group) {
70
+				$this->group->enqueue($this->group, $this->page);
71 71
 			}
72 72
 
73
-			$this->page->enqueue( $this->page );
73
+			$this->page->enqueue($this->page);
74 74
 		}
75 75
 	}
76 76
 }
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
@@ -45,7 +45,7 @@  discard block
 block discarded – undo
45 45
 	/** @var \PinkCrab\Perique_Admin_Menu\Registrar\Registrar */
46 46
 	protected $registrar;
47 47
 
48
-	public function __construct( DI_Container $di_container, View $view, Registrar $registrar ) {
48
+	public function __construct(DI_Container $di_container, View $view, Registrar $registrar) {
49 49
 		$this->di_container = $di_container;
50 50
 		$this->view         = $view;
51 51
 		$this->registrar    = $registrar;
@@ -57,10 +57,10 @@  discard block
 block discarded – undo
57 57
 	 * @param \PinkCrab\Perique_Admin_Menu\Group\Abstract_Group $group
58 58
 	 * @return void
59 59
 	 */
60
-	public function register_group( Abstract_Group $group ): void {
60
+	public function register_group(Abstract_Group $group): void {
61 61
 
62 62
 		// If current user can not access the group, bail without attempting to register.
63
-		if ( ! current_user_can( $group->get_capability() ) ) {
63
+		if ( ! current_user_can($group->get_capability())) {
64 64
 			return;
65 65
 		}
66 66
 
@@ -68,20 +68,20 @@  discard block
 block discarded – undo
68 68
 
69 69
 			// Validate the group.
70 70
 			$validator = new Group_Validator();
71
-			if ( ! $validator->validate( $group ) ) {
72
-				throw Group_Exception::failed_validation( $validator, $group );
71
+			if ( ! $validator->validate($group)) {
72
+				throw Group_Exception::failed_validation($validator, $group);
73 73
 			}
74 74
 
75
-			$this->register_primary_page( $group );
75
+			$this->register_primary_page($group);
76 76
 
77 77
 			// Register all pages and attempt to set primary page name in menu.
78
-			foreach ( $this->get_pages( $group ) as $page ) {
79
-				$this->register_subpage( $page, $this->get_primary_page( $group )->slug(), $group );
78
+			foreach ($this->get_pages($group) as $page) {
79
+				$this->register_subpage($page, $this->get_primary_page($group)->slug(), $group);
80 80
 			}
81
-			$this->set_primary_page_details( $group );
81
+			$this->set_primary_page_details($group);
82 82
 
83
-		} catch ( \Throwable $th ) {
84
-			$this->admin_exception_notice( $group, $th );
83
+		} catch (\Throwable $th) {
84
+			$this->admin_exception_notice($group, $th);
85 85
 		}
86 86
 	}
87 87
 
@@ -92,22 +92,22 @@  discard block
 block discarded – undo
92 92
 	 * @param \Throwable $exception
93 93
 	 * @return void
94 94
 	 */
95
-	public function admin_exception_notice( $object, Throwable $exception ): void {
95
+	public function admin_exception_notice($object, Throwable $exception): void {
96 96
 		add_action(
97 97
 			'admin_notices',
98
-			function() use ( $object, $exception ) {
98
+			function() use ($object, $exception) {
99 99
 				$class   = 'notice notice-error';
100 100
 				$message = sprintf(
101 101
 					'%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>',
102
-					get_class( $object ) === Page::class ? 'Page' : 'Menu Group',
103
-					get_class( $object ),
102
+					get_class($object) === Page::class ? 'Page' : 'Menu Group',
103
+					get_class($object),
104 104
 					$exception->getMessage(),
105 105
 					$exception->getFile(),
106 106
 					$exception->getLine()
107 107
 				);
108 108
 				printf(
109 109
 					'<div class="%1$s"><p>%2$s</p></div>',
110
-					esc_attr( $class ),
110
+					esc_attr($class),
111 111
 					wp_kses(
112 112
 						$message,
113 113
 						array(
@@ -127,9 +127,9 @@  discard block
 block discarded – undo
127 127
 	 * @param \PinkCrab\Perique_Admin_Menu\Group\Abstract_Group $group
128 128
 	 * @return void
129 129
 	 */
130
-	protected function register_primary_page( Abstract_Group $group ): void {
130
+	protected function register_primary_page(Abstract_Group $group): void {
131 131
 		$this->registrar->register_primary(
132
-			$this->get_primary_page( $group ),
132
+			$this->get_primary_page($group),
133 133
 			$group
134 134
 		);
135 135
 	}
@@ -140,17 +140,17 @@  discard block
 block discarded – undo
140 140
 	 * @param \PinkCrab\Perique_Admin_Menu\Group\Abstract_Group $group
141 141
 	 * @return \PinkCrab\Perique_Admin_Menu\Page\Page
142 142
 	 */
143
-	protected function get_primary_page( Abstract_Group $group ): Page {
143
+	protected function get_primary_page(Abstract_Group $group): Page {
144 144
 		/** @var Page */
145
-		$page = $this->di_container->create( $group->get_primary_page() );
145
+		$page = $this->di_container->create($group->get_primary_page());
146 146
 
147
-		if ( ! is_object( $page ) || ! is_a( $page, Page::class ) ) {
148
-			throw Page_Exception::invalid_page_type( $page );
147
+		if ( ! is_object($page) || ! is_a($page, Page::class)) {
148
+			throw Page_Exception::invalid_page_type($page);
149 149
 		}
150 150
 
151 151
 		// Register view if requied.
152
-		if ( \method_exists( $page, 'set_view' ) ) {
153
-			$page->set_view( $this->view );
152
+		if (\method_exists($page, 'set_view')) {
153
+			$page->set_view($this->view);
154 154
 		}
155 155
 
156 156
 		return $page;
@@ -164,18 +164,18 @@  discard block
 block discarded – undo
164 164
 	 * @return array<Page>
165 165
 	 * @throws Page_Exception (Code 202)
166 166
 	 */
167
-	protected function get_pages( Abstract_Group $group ): array {
167
+	protected function get_pages(Abstract_Group $group): array {
168 168
 		return array_map(
169
-			function( string $page ): Page {
170
-				$constructed_page = $this->di_container->create( $page );
171
-				if ( ! is_object( $constructed_page ) || ! is_a( $constructed_page, Page::class ) ) {
172
-					throw Page_Exception::invalid_page_type( $constructed_page );
169
+			function(string $page): Page {
170
+				$constructed_page = $this->di_container->create($page);
171
+				if ( ! is_object($constructed_page) || ! is_a($constructed_page, Page::class)) {
172
+					throw Page_Exception::invalid_page_type($constructed_page);
173 173
 				}
174 174
 				return $constructed_page;
175 175
 			},
176 176
 			array_filter(
177 177
 				$group->get_pages(),
178
-				function( string $page ) use ( $group ) {
178
+				function(string $page) use ($group) {
179 179
 					return $page !== $group->get_primary_page();
180 180
 				}
181 181
 			)
@@ -191,22 +191,22 @@  discard block
 block discarded – undo
191 191
 	 * @phpcs:disable WordPress.WP.GlobalVariablesOverride.Prohibited
192 192
 	 * @throws Group_Exception (code 253)
193 193
 	 */
194
-	protected function set_primary_page_details( Abstract_Group $group ) {
194
+	protected function set_primary_page_details(Abstract_Group $group) {
195 195
 		global $submenu;
196 196
 
197
-		$primary = $this->get_primary_page( $group );
197
+		$primary = $this->get_primary_page($group);
198 198
 
199
-		if ( ! array_key_exists( $primary->slug(), $submenu ) ) {
199
+		if ( ! array_key_exists($primary->slug(), $submenu)) {
200 200
 			return;
201 201
 		}
202 202
 
203 203
 		$primary_page_key = array_search(
204 204
 			$primary->slug(),
205
-			\array_column( $submenu[ $primary->slug() ], 2 ),
205
+			\array_column($submenu[$primary->slug()], 2),
206 206
 			true
207 207
 		) ?: 0;
208 208
 
209
-		$submenu[ $primary->slug() ][ $primary_page_key ][0] = $primary->menu_title();
209
+		$submenu[$primary->slug()][$primary_page_key][0] = $primary->menu_title();
210 210
 	}
211 211
 
212 212
 
@@ -218,21 +218,21 @@  discard block
 block discarded – undo
218 218
 	 * @param \PinkCrab\Perique_Admin_Menu\Group\Abstract_Group|null $group
219 219
 	 * @return void
220 220
 	 */
221
-	public function register_subpage( Page $page, string $parent_slug, ?Abstract_Group $group = null ): void {
221
+	public function register_subpage(Page $page, string $parent_slug, ?Abstract_Group $group = null): void {
222 222
 		// If user cant access the page, bail before attempting to register.
223
-		if ( ! current_user_can( $page->capability() ) ) {
223
+		if ( ! current_user_can($page->capability())) {
224 224
 			return;
225 225
 		}
226 226
 
227 227
 		// Register view if required.
228
-		if ( \method_exists( $page, 'set_view' ) ) {
229
-			$page->set_view( $this->view );
228
+		if (\method_exists($page, 'set_view')) {
229
+			$page->set_view($this->view);
230 230
 		}
231 231
 
232 232
 		try {
233
-			$this->registrar->register_subpage( $page, $parent_slug, $group );
234
-		} catch ( \Throwable $th ) {
235
-			$this->admin_exception_notice( $page, $th );
233
+			$this->registrar->register_subpage($page, $parent_slug, $group);
234
+		} catch (\Throwable $th) {
235
+			$this->admin_exception_notice($page, $th);
236 236
 		}
237 237
 	}
238 238
 
@@ -242,16 +242,16 @@  discard block
 block discarded – undo
242 242
 	 * @param \PinkCrab\Perique_Admin_Menu\Page\Page $page
243 243
 	 * @return void
244 244
 	 */
245
-	public function register_single_page( Page $page ): void {
245
+	public function register_single_page(Page $page): void {
246 246
 		// Register view if required.
247
-		if ( \method_exists( $page, 'set_view' ) ) {
248
-			$page->set_view( $this->view );
247
+		if (\method_exists($page, 'set_view')) {
248
+			$page->set_view($this->view);
249 249
 		}
250 250
 
251 251
 		try {
252
-			$this->registrar->register_primary( $page, null );
253
-		} catch ( \Throwable $th ) {
254
-			$this->admin_exception_notice( $page, $th );
252
+			$this->registrar->register_primary($page, null);
253
+		} catch (\Throwable $th) {
254
+			$this->admin_exception_notice($page, $th);
255 255
 		}
256 256
 	}
257 257
 
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
@@ -44,7 +44,7 @@  discard block
 block discarded – undo
44 44
 	 */
45 45
 	protected $group;
46 46
 
47
-	public function __construct( Page $page, ?Abstract_Group $group = null ) {
47
+	public function __construct(Page $page, ?Abstract_Group $group = null) {
48 48
 		$this->page  = $page;
49 49
 		$this->group = $group;
50 50
 	}
@@ -56,10 +56,10 @@  discard block
 block discarded – undo
56 56
 	 */
57 57
 	public function __invoke() {
58 58
 		// Register hooks for the group if part of group
59
-		if ( null !== $this->group ) {
60
-			$this->group->load( $this->group, $this->page );
59
+		if (null !== $this->group) {
60
+			$this->group->load($this->group, $this->page);
61 61
 		}
62 62
 
63
-		$this->page->load( $this->page );
63
+		$this->page->load($this->page);
64 64
 	}
65 65
 }
Please login to merge, or discard this patch.
src/Group/Abstract_Group.php 1 patch
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -84,8 +84,8 @@  discard block
 block discarded – undo
84 84
 	 * @return string
85 85
 	 */
86 86
 	public function get_group_title(): string {
87
-		if ( $this->group_title === null ) {
88
-			throw Group_Exception::group_title_undefined( $this );
87
+		if ($this->group_title === null) {
88
+			throw Group_Exception::group_title_undefined($this);
89 89
 		}
90 90
 		return $this->group_title;
91 91
 	}
@@ -114,8 +114,8 @@  discard block
 block discarded – undo
114 114
 	 * @return string
115 115
 	 */
116 116
 	public function get_primary_page(): string {
117
-		if ( $this->primary_page === null ) {
118
-			throw Group_Exception::primary_page_undefined( $this );
117
+		if ($this->primary_page === null) {
118
+			throw Group_Exception::primary_page_undefined($this);
119 119
 		}
120 120
 		return $this->primary_page;
121 121
 	}
@@ -146,7 +146,7 @@  discard block
 block discarded – undo
146 146
 	 * @return void
147 147
 	 * @codeCoverageIgnore This can't be tested as it does nothing and is extended only
148 148
 	 */
149
-	public function enqueue( Abstract_Group $group, Page $page ): void {
149
+	public function enqueue(Abstract_Group $group, Page $page): void {
150 150
 		// Do nothing by default.
151 151
 	}
152 152
 
@@ -158,7 +158,7 @@  discard block
 block discarded – undo
158 158
 	 * @return void
159 159
 	 * @codeCoverageIgnore This can't be tested as it does nothing and is extended only
160 160
 	 */
161
-	public function load( Abstract_Group $group, Page $page ): void {
161
+	public function load(Abstract_Group $group, Page $page): void {
162 162
 		// Do nothing by default.
163 163
 	}
164 164
 }
Please login to merge, or discard this patch.