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

ParameterizedSearchBuilder::addLimit()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 6
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 3
nc 1
nop 2
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
}