Passed
Branch master (249862)
by Adam
07:51
created

AdBuilder::build()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 23
Code Lines 16

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 16
nc 1
nop 0
dl 0
loc 23
rs 9.0856
c 0
b 0
f 0
1
<?php
2
3
namespace Coyote\Services\Elasticsearch\Builders\Job;
4
5
use Coyote\Services\Elasticsearch\Filters\Term;
6
use Coyote\Services\Elasticsearch\Functions\Random;
7
use Coyote\Services\Elasticsearch\QueryBuilder;
8
use Coyote\Services\Elasticsearch\QueryString;
9
10
class AdBuilder extends SearchBuilder
11
{
12
    /**
13
     * @param array $tags
14
     */
15
    public function boostTags(array $tags)
16
    {
17
        $this->should(new QueryString(implode(' ', $tags), ['title^4', 'tags^2', 'description'], 3));
18
    }
19
20
    /**
21
     * @return array
22
     */
23
    public function build()
24
    {
25
        // only premium offers
26
        $this->must(new Term('is_ads', true));
27
28
        $this->score(new Random());
29
        $this->size(0, 4);
30
31
        $this->source([
32
            'id',
33
            'title',
34
            'slug',
35
            'is_remote',
36
            'remote_range',
37
            'firm.*',
38
            'locations',
39
            'tags',
40
            'currency_symbol',
41
            'salary_from',
42
            'salary_to'
43
        ]);
44
45
        return QueryBuilder::build();
0 ignored issues
show
Bug Best Practice introduced by
The method Coyote\Services\Elastics...h\QueryBuilder::build() is not static, but was called statically. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

45
        return QueryBuilder::/** @scrutinizer ignore-call */ build();
Loading history...
46
    }
47
}
48