Passed
Push — master ( f2dd2f...70c2c9 )
by Elvis Henrique
08:46
created

Example   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 21
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 2
eloc 11
c 1
b 0
f 0
dl 0
loc 21
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A find_by_author_id() 0 15 1
A find_one_by_post() 0 2 1
1
<?php declare(strict_types = 1);
2
3
namespace App\Repositories;
4
5
use App\Entities\Example as Entity;
6
use App\Entities\Examples;
7
use WPSteak\Repositories\AbstractPost;
8
9
/** @codeCoverageIgnore */
10
class Example extends AbstractPost {
11
12
	public function find_one_by_post( \WP_Post $post ): ?Entity {
13
		return new Entity( $post, $this->meta->get( (int) $post->ID, 'address', true ) );
14
	}
15
16
	public function find_by_author_id( int $author_id, int $quantity ): Examples {
17
		$posts = $this->get_posts(
18
			[
19
				'numberposts' => $quantity,
20
				'author' => $author_id,
21
			],
22
		);
23
24
		return new Examples(
25
			...array_map(
26
				fn ( \WP_Post $post ) => new Entity(
27
					$post,
28
					$this->meta->get( (int) $post->ID, 'address', true ),
29
				),
30
				$posts,
31
			),
32
		);
33
	}
34
35
}
36