SearchExpression   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 33
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Importance

Changes 3
Bugs 0 Features 2
Metric Value
wmc 2
c 3
b 0
f 2
lcom 1
cbo 0
dl 0
loc 33
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A addCondition() 0 6 1
A __toString() 0 4 1
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