ReadsHandlerMiddlewareTrait   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 15
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 2
eloc 5
c 1
b 0
f 0
dl 0
loc 15
ccs 5
cts 5
cp 1
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A getHandlerMiddleware() 0 8 2
1
<?php
2
/**
3
 * @package   WPEmerge
4
 * @author    Atanas Angelov <[email protected]>
5
 * @copyright 2017-2019 Atanas Angelov
6
 * @license   https://www.gnu.org/licenses/gpl-2.0.html GPL-2.0
7
 * @link      https://wpemerge.com/
8
 */
9
10
namespace WPEmerge\Middleware;
11
12
use WPEmerge\Helpers\Handler;
13
14
/**
15
 * Describes how a request is handled.
16
 */
17
trait ReadsHandlerMiddlewareTrait {
18
	/**
19
	 * Get middleware registered with the given handler.
20
	 *
21
	 * @param  Handler  $handler
22
	 * @return string[]
23
	 */
24 2
	protected function getHandlerMiddleware( Handler $handler ) {
25 2
		$instance = $handler->make();
26
27 2
		if ( ! $instance instanceof HasControllerMiddlewareInterface ) {
28 1
			return [];
29
		}
30
31 1
		return $instance->getMiddleware( $handler->get()['method'] );
32
	}
33
}
34