AbstractText   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 41
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Importance

Changes 1
Bugs 0 Features 1
Metric Value
wmc 5
c 1
b 0
f 1
lcom 0
cbo 1
dl 0
loc 41
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 6 3
A setText() 0 4 1
A __toString() 0 4 1
1
<?php
2
3
namespace Ddeboer\Imap\Search\Text;
4
5
use Ddeboer\Imap\Search\AbstractCondition;
6
7
/**
8
 * Represents a text based condition. Text based conditions use a contains
9
 * restriction.
10
 */
11
abstract class AbstractText extends AbstractCondition
12
{
13
    /**
14
     * Text to be used for the condition.
15
     *
16
     * @var string
17
     */
18
    protected $text;
19
20
    /**
21
     * Constructor.
22
     *
23
     * @param string $text Optional text for the condition.
24
     */
25
    public function __construct($text = null)
26
    {
27
        if (!is_null($text) && strlen($text) > 0) {
28
            $this->setText($text);
29
        }
30
    }
31
32
    /**
33
     * Sets the text for the condition.
34
     *
35
     * @param string $text
36
     */
37
    public function setText($text)
38
    {
39
        $this->text = $text;
40
    }
41
42
    /**
43
     * Converts the condition to a string that can be sent to the IMAP server.
44
     *
45
     * @return string
46
     */
47
    public function __toString()
48
    {
49
        return $this->getKeyword() . ' "' . str_replace('"', '\\"', $this->text) . '"';
50
    }
51
}
52