2017-08-11 22:56:23 +02:00
|
|
|
<?php
|
|
|
|
/**
|
|
|
|
* @author clivern <hello@clivern.com>
|
|
|
|
*/
|
|
|
|
|
|
|
|
namespace Clivern\Imap\Core;
|
|
|
|
|
2017-08-12 01:25:32 +02:00
|
|
|
use Clivern\Imap\Core\Search\Contract\Condition;
|
|
|
|
|
2017-08-11 22:56:23 +02:00
|
|
|
/**
|
|
|
|
* Search Class
|
|
|
|
*
|
|
|
|
* @package Clivern\Imap\Core
|
|
|
|
*/
|
|
|
|
class Search
|
|
|
|
{
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @var array
|
|
|
|
*/
|
|
|
|
protected $conditions = [];
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Add Condition
|
|
|
|
*
|
2017-08-12 01:25:32 +02:00
|
|
|
* @param Condition $condition
|
2017-08-11 22:56:23 +02:00
|
|
|
* @return Search
|
|
|
|
*/
|
2017-08-12 01:25:32 +02:00
|
|
|
public function addCondition(Condition $condition)
|
2017-08-11 22:56:23 +02:00
|
|
|
{
|
2017-08-12 01:25:32 +02:00
|
|
|
$this->conditions[] = (string) $condition;
|
2017-08-11 22:56:23 +02:00
|
|
|
|
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Get Conditions
|
|
|
|
*
|
|
|
|
* @return array
|
|
|
|
*/
|
|
|
|
public function getConditions()
|
|
|
|
{
|
|
|
|
return $this->conditions;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Get Conditions Query
|
|
|
|
*
|
|
|
|
* @return string
|
|
|
|
*/
|
|
|
|
public function __toString()
|
|
|
|
{
|
|
|
|
return (!empty($this->conditions)) ? implode(" ", $this->conditions) : "";
|
|
|
|
}
|
|
|
|
}
|