Failed Conditions
Push — develop ( d7a728...605806 )
by Elvis Henrique
04:12
created

Page::find_by_id()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 8
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 5
CRAP Score 2

Importance

Changes 0
Metric Value
eloc 4
dl 0
loc 8
c 0
b 0
f 0
ccs 5
cts 5
cp 1
rs 10
cc 2
nc 2
nop 1
crap 2
1
<?php
2
/**
3
 * Page.
4
 *
5
 * @package App
6
 */
7
8
declare(strict_types=1);
9
10
namespace App\Repositories;
11
12
use App\Entities\Page as Entity;
13
14
/**
15
 * Page class.
16
 */
17
class Page extends AbstractPost {
18
19
	/**
20
	 * Find by id.
21
	 *
22
	 * @param integer $id Id.
23
	 * @return Entity|null
24
	 */
25 2
	public function find_by_id( int $id ) : ?Entity {
26 2
		$post = $this->get_post( $id );
27
28 2
		if ( ! $post ) {
0 ignored issues
show
introduced by
$post is of type WP_Post, thus it always evaluated to true.
Loading history...
29 1
			return null;
30
		}
31
32 1
		return ( new Entity() )->set_post( $post );
33
	}
34
}
35