Post::get_posts()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 2
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 1
c 1
b 0
f 0
nc 1
nop 1
dl 0
loc 2
rs 10
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