Completed
Pull Request — master (#10)
by
unknown
02:57
created

ParameterizedSearchBuilder   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 78
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Importance

Changes 0
Metric Value
wmc 6
lcom 1
cbo 0
dl 0
loc 78
rs 10
c 0
b 0
f 0

6 Methods

Rating   Name   Duplication   Size   Complexity  
A search() 0 6 1
A addTable() 0 6 1
A select() 0 6 1
A addSelect() 0 6 1
A addLimit() 0 6 1
A getQuery() 0 4 1
1
<?php
2
3
namespace Akeneo\SalesForce\Search;
4
5
/**
6
 * @author Emmanuel Ripoll <[email protected]>
7
 */
8
class ParameterizedSearchBuilder
9
{
10
    /**
11
     * @var string
12
     */
13
    protected $query = '';
14
15
    /**
16
     * @param string $value
17
     *
18
     * @return ParameterizedSearchBuilder
19
     */
20
    public function search(string $value): ParameterizedSearchBuilder
21
    {
22
        $this->query = sprintf($value);
23
24
        return $this;
25
    }
26
27
    /**
28
     * @param string $table
29
     *
30
     * @return ParameterizedSearchBuilder
31
     */
32
    public function addTable(string $table): ParameterizedSearchBuilder
33
    {
34
        $this->query = sprintf('%s&sobject=%s', $this->query, $table);
35
36
        return $this;
37
    }
38
39
    /**
40
     * @param string $table
41
     * @param string $field
42
     *
43
     * @return ParameterizedSearchBuilder
44
     */
45
    public function select(string $table, string $field): ParameterizedSearchBuilder
46
    {
47
        $this->query = sprintf('%s&%s.fields=%s', $this->query, $table, $field);
48
49
        return $this;
50
    }
51
52
    /**
53
     * @param string $field
54
     *
55
     * @return ParameterizedSearchBuilder
56
     */
57
    public function addSelect(string $field): ParameterizedSearchBuilder
58
    {
59
        $this->query = sprintf('%s,%s', $this->query, $field);
60
61
        return $this;
62
    }
63
64
    /**
65
     * @param int $limit
66
     * @param string $table
67
     *
68
     * @return ParameterizedSearchBuilder
69
     */
70
    public function addLimit(int $limit, string $table): ParameterizedSearchBuilder
71
    {
72
        $this->query = sprintf('%s&%s.limit=%s', $this->query, $table, $limit);
73
74
        return $this;
75
    }
76
77
    /**
78
     * @return string
79
     */
80
    public function getQuery(): string
81
    {
82
        return $this->query;
83
    }
84
85
}