Delete   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 61
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
wmc 5
lcom 1
cbo 1
dl 0
loc 61
ccs 0
cts 22
cp 0
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A addId() 0 5 1
A addQuery() 0 5 1
A renderBody() 0 15 3
1
<?php
2
3
namespace PSolr\Request;
4
5
/**
6
 * @see http://wiki.apache.org/solr/UpdateXmlMessages#A.22delete.22_documents_by_ID_and_by_Query
7
 */
8
class Delete extends SolrRequest
9
{
10
    /**
11
     * @var string
12
     */
13
    protected $handlerName = 'update';
14
15
    /**
16
     * $var string
17
     */
18
    protected $responseClass = '\PSolr\Response\Response';
19
20
    /**
21
     * @var array
22
     */
23
    protected $ids = array();
24
25
    /**
26
     * @var array
27
     */
28
    protected $queries = array();
29
30
    /**
31
     * @param string $id
32
     *
33
     * @return \PSolr\Request\Delete
34
     */
35
    public function addId($id)
36
    {
37
        $this->ids[] = $id;
38
        return $this;
39
    }
40
41
    /**
42
     * @param string $query
43
     */
44
    public function addQuery($query)
45
    {
46
        $this->queries[] = $query;
47
        return $this;
48
    }
49
50
    /**
51
     * {@inheritDoc}
52
     */
53
    public function renderBody()
54
    {
55
        $xml = '<delete>';
56
57
        foreach ($this->ids as $id) {
58
            $xml .= '<id>' . SolrRequest::escapeXml($id) . '</id>';
59
        }
60
61
        foreach ($this->queries as $query) {
62
            $xml .= '<query>' . SolrRequest::escapeXml($query) . '</query>';
63
        }
64
65
        $xml .= '</delete>';
66
        return SolrRequest::stripCtrlChars($xml);
67
    }
68
}
69