Post   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 23
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 8
c 1
b 0
f 0
dl 0
loc 23
rs 10
wmc 4

2 Methods

Rating   Name   Duplication   Size   Complexity  
A get_posts() 0 2 1
A get_post() 0 12 3
1
<?php declare(strict_types = 1);
2
3
namespace WPSteak\Repositories;
4
5
/** @codeCoverageIgnore */
6
abstract class Post {
7
8
	/** @param \WP_Post|int $post The post object or id. */
9
	protected function get_post( $post ): ?\WP_Post {
10
		if ( $post instanceof \WP_Post ) {
11
			return $post;
12
		}
13
14
		$result = get_post( $post );
15
16
		if ( ! $result instanceof \WP_Post ) {
0 ignored issues
show
introduced by
$result is always a sub-type of WP_Post.
Loading history...
17
			return null;
18
		}
19
20
		return $result;
21
	}
22
23
	/**
24
	 * @param array<string> $args Args.
25
	 * @return array<\WP_Post>|array<int>
26
	 */
27
	protected function get_posts( array $args ): array {
28
		return get_posts( $args );
29
	}
30
31
}
32