Passed
Push — develop ( 39ad60...0ca1de )
by Paul
14:09
created

SearchPostId   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 23
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 3
eloc 16
dl 0
loc 23
ccs 0
cts 17
cp 0
rs 10
c 1
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A handle() 0 21 3
1
<?php
2
3
namespace GeminiLabs\SiteReviews\Integrations\Bricks\Commands;
4
5
use GeminiLabs\SiteReviews\Database;
6
7
class SearchPostId extends AbstractSearchCommand
8
{
9
    public function handle(): void
10
    {
11
        $this->verifyNonce();
12
        $args = [
13
            'post__in' => [],
14
            'post_type' => glsr()->post_type,
15
            'posts_per_page' => 25,
16
        ];
17
        if (is_numeric($this->search)) {
18
            $args['post__in'][] = (int) $this->search;
19
        } else {
20
            $args['s'] = (string) $this->search;
21
        }
22
        $results = glsr(Database::class)->posts($args);
23
        if ($missingIds = $this->missingIds($results, $this->include)) {
24
            $results += glsr(Database::class)->posts([
25
                'post__in' => $missingIds,
26
                'post_type' => glsr()->post_type,
27
            ]);
28
        }
29
        $this->response = $this->formatResults($results);
30
    }
31
}
32