SearchExpression::__toString()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 2
Bugs 0 Features 1
Metric Value
c 2
b 0
f 1
dl 0
loc 4
rs 10
cc 1
eloc 2
nc 1
nop 0
1
<?php
2
3
namespace Ddeboer\Imap;
4
5
use Ddeboer\Imap\Search\AbstractCondition;
6
7
/**
8
 * Defines a search expression that can be used to look up email messages.
9
 */
10
class SearchExpression
11
{
12
    /**
13
     * The conditions that together represent the expression.
14
     *
15
     * @var array
16
     */
17
    private $conditions = array();
18
19
    /**
20
     * Adds a new condition to the expression.
21
     *
22
     * @param  AbstractCondition $condition The condition to be added.
23
     *
24
     * @return SearchExpression
25
     */
26
    public function addCondition(AbstractCondition $condition)
27
    {
28
        $this->conditions[] = $condition;
29
30
        return $this;
31
    }
32
33
    /**
34
     * Converts the expression to a string that can be sent to the IMAP server.
35
     *
36
     * @return string
37
     */
38
    public function __toString()
39
    {
40
        return implode(' ', $this->conditions);
41
    }
42
}
43