clivern-imap/src/Core/Search.php

55 lines
868 B
PHP
Raw Normal View History

<?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;
/**
* 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
* @return Search
*/
2017-08-12 01:25:32 +02:00
public function addCondition(Condition $condition)
{
2017-08-12 01:25:32 +02:00
$this->conditions[] = (string) $condition;
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) : "";
}
}