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

AdBuilder   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 36
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
dl 0
loc 36
rs 10
c 0
b 0
f 0
wmc 2

2 Methods

Rating   Name   Duplication   Size   Complexity  
A boostTags() 0 3 1
A build() 0 23 1
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