search flags added
This commit is contained in:
parent
a2dc59b84a
commit
b0fef24df4
28 changed files with 844 additions and 8 deletions
|
|
@ -5,6 +5,8 @@
|
|||
|
||||
namespace Clivern\Imap\Core;
|
||||
|
||||
use Clivern\Imap\Core\Search\Contract\Condition;
|
||||
|
||||
/**
|
||||
* Search Class
|
||||
*
|
||||
|
|
@ -21,12 +23,12 @@ class Search
|
|||
/**
|
||||
* Add Condition
|
||||
*
|
||||
* @param string $condition
|
||||
* @param Condition $condition
|
||||
* @return Search
|
||||
*/
|
||||
public function addCondition($condition)
|
||||
public function addCondition(Condition $condition)
|
||||
{
|
||||
$this->conditions[] = $condition;
|
||||
$this->conditions[] = (string) $condition;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
|
|
|||
26
src/Core/Search/Condition/All.php
Normal file
26
src/Core/Search/Condition/All.php
Normal file
|
|
@ -0,0 +1,26 @@
|
|||
<?php
|
||||
/**
|
||||
* @author clivern <hello@clivern.com>
|
||||
*/
|
||||
|
||||
namespace Clivern\Imap\Core\Search\Condition;
|
||||
|
||||
use Clivern\Imap\Core\Search\Contract\Condition;
|
||||
|
||||
/**
|
||||
* All Class
|
||||
*
|
||||
* @package Clivern\Imap\Core\Search\Condition
|
||||
*/
|
||||
class All implements Condition
|
||||
{
|
||||
/**
|
||||
* Query String
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function __toString()
|
||||
{
|
||||
return "ALL";
|
||||
}
|
||||
}
|
||||
26
src/Core/Search/Condition/Answered.php
Normal file
26
src/Core/Search/Condition/Answered.php
Normal file
|
|
@ -0,0 +1,26 @@
|
|||
<?php
|
||||
/**
|
||||
* @author clivern <hello@clivern.com>
|
||||
*/
|
||||
|
||||
namespace Clivern\Imap\Core\Search\Condition;
|
||||
|
||||
use Clivern\Imap\Core\Search\Contract\Condition;
|
||||
|
||||
/**
|
||||
* Answered Class
|
||||
*
|
||||
* @package Clivern\Imap\Core\Search\Condition
|
||||
*/
|
||||
class Answered implements Condition
|
||||
{
|
||||
/**
|
||||
* Query String
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function __toString()
|
||||
{
|
||||
return "ANSWERED";
|
||||
}
|
||||
}
|
||||
42
src/Core/Search/Condition/BCC.php
Normal file
42
src/Core/Search/Condition/BCC.php
Normal file
|
|
@ -0,0 +1,42 @@
|
|||
<?php
|
||||
/**
|
||||
* @author clivern <hello@clivern.com>
|
||||
*/
|
||||
|
||||
namespace Clivern\Imap\Core\Search\Condition;
|
||||
|
||||
use Clivern\Imap\Core\Search\Contract\Condition;
|
||||
|
||||
/**
|
||||
* BCC Class
|
||||
*
|
||||
* @package Clivern\Imap\Core\Search\Condition
|
||||
*/
|
||||
class BCC implements Condition
|
||||
{
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
protected $data;
|
||||
|
||||
/**
|
||||
* Class Constructor
|
||||
*
|
||||
* @param string $data
|
||||
*/
|
||||
public function __construct($data)
|
||||
{
|
||||
$this->data = $data;
|
||||
}
|
||||
|
||||
/**
|
||||
* Query String
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function __toString()
|
||||
{
|
||||
return "BCC \"{$this->data}\"";
|
||||
}
|
||||
}
|
||||
42
src/Core/Search/Condition/Before.php
Normal file
42
src/Core/Search/Condition/Before.php
Normal file
|
|
@ -0,0 +1,42 @@
|
|||
<?php
|
||||
/**
|
||||
* @author clivern <hello@clivern.com>
|
||||
*/
|
||||
|
||||
namespace Clivern\Imap\Core\Search\Condition;
|
||||
|
||||
use Clivern\Imap\Core\Search\Contract\Condition;
|
||||
|
||||
/**
|
||||
* Before Class
|
||||
*
|
||||
* @package Clivern\Imap\Core\Search\Condition
|
||||
*/
|
||||
class Before implements Condition
|
||||
{
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
protected $data;
|
||||
|
||||
/**
|
||||
* Class Constructor
|
||||
*
|
||||
* @param string $data
|
||||
*/
|
||||
public function __construct($data)
|
||||
{
|
||||
$this->data = $data;
|
||||
}
|
||||
|
||||
/**
|
||||
* Query String
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function __toString()
|
||||
{
|
||||
return "BEFORE \"{$this->data}\"";
|
||||
}
|
||||
}
|
||||
42
src/Core/Search/Condition/Body.php
Normal file
42
src/Core/Search/Condition/Body.php
Normal file
|
|
@ -0,0 +1,42 @@
|
|||
<?php
|
||||
/**
|
||||
* @author clivern <hello@clivern.com>
|
||||
*/
|
||||
|
||||
namespace Clivern\Imap\Core\Search\Condition;
|
||||
|
||||
use Clivern\Imap\Core\Search\Contract\Condition;
|
||||
|
||||
/**
|
||||
* Body Class
|
||||
*
|
||||
* @package Clivern\Imap\Core\Search\Condition
|
||||
*/
|
||||
class Body implements Condition
|
||||
{
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
protected $data;
|
||||
|
||||
/**
|
||||
* Class Constructor
|
||||
*
|
||||
* @param string $data
|
||||
*/
|
||||
public function __construct($data)
|
||||
{
|
||||
$this->data = $data;
|
||||
}
|
||||
|
||||
/**
|
||||
* Query String
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function __toString()
|
||||
{
|
||||
return "BODY \"{$this->data}\"";
|
||||
}
|
||||
}
|
||||
42
src/Core/Search/Condition/CC.php
Normal file
42
src/Core/Search/Condition/CC.php
Normal file
|
|
@ -0,0 +1,42 @@
|
|||
<?php
|
||||
/**
|
||||
* @author clivern <hello@clivern.com>
|
||||
*/
|
||||
|
||||
namespace Clivern\Imap\Core\Search\Condition;
|
||||
|
||||
use Clivern\Imap\Core\Search\Contract\Condition;
|
||||
|
||||
/**
|
||||
* CC Class
|
||||
*
|
||||
* @package Clivern\Imap\Core\Search\Condition
|
||||
*/
|
||||
class CC implements Condition
|
||||
{
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
protected $data;
|
||||
|
||||
/**
|
||||
* Class Constructor
|
||||
*
|
||||
* @param string $data
|
||||
*/
|
||||
public function __construct($data)
|
||||
{
|
||||
$this->data = $data;
|
||||
}
|
||||
|
||||
/**
|
||||
* Query String
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function __toString()
|
||||
{
|
||||
return "CC \"{$this->data}\"";
|
||||
}
|
||||
}
|
||||
26
src/Core/Search/Condition/Deleted.php
Normal file
26
src/Core/Search/Condition/Deleted.php
Normal file
|
|
@ -0,0 +1,26 @@
|
|||
<?php
|
||||
/**
|
||||
* @author clivern <hello@clivern.com>
|
||||
*/
|
||||
|
||||
namespace Clivern\Imap\Core\Search\Condition;
|
||||
|
||||
use Clivern\Imap\Core\Search\Contract\Condition;
|
||||
|
||||
/**
|
||||
* Deleted Class
|
||||
*
|
||||
* @package Clivern\Imap\Core\Search\Condition
|
||||
*/
|
||||
class Deleted implements Condition
|
||||
{
|
||||
/**
|
||||
* Query String
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function __toString()
|
||||
{
|
||||
return "DELETED";
|
||||
}
|
||||
}
|
||||
26
src/Core/Search/Condition/Flagged.php
Normal file
26
src/Core/Search/Condition/Flagged.php
Normal file
|
|
@ -0,0 +1,26 @@
|
|||
<?php
|
||||
/**
|
||||
* @author clivern <hello@clivern.com>
|
||||
*/
|
||||
|
||||
namespace Clivern\Imap\Core\Search\Condition;
|
||||
|
||||
use Clivern\Imap\Core\Search\Contract\Condition;
|
||||
|
||||
/**
|
||||
* Flagged Class
|
||||
*
|
||||
* @package Clivern\Imap\Core\Search\Condition
|
||||
*/
|
||||
class Flagged implements Condition
|
||||
{
|
||||
/**
|
||||
* Query String
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function __toString()
|
||||
{
|
||||
return "FLAGGED";
|
||||
}
|
||||
}
|
||||
42
src/Core/Search/Condition/From.php
Normal file
42
src/Core/Search/Condition/From.php
Normal file
|
|
@ -0,0 +1,42 @@
|
|||
<?php
|
||||
/**
|
||||
* @author clivern <hello@clivern.com>
|
||||
*/
|
||||
|
||||
namespace Clivern\Imap\Core\Search\Condition;
|
||||
|
||||
use Clivern\Imap\Core\Search\Contract\Condition;
|
||||
|
||||
/**
|
||||
* From Class
|
||||
*
|
||||
* @package Clivern\Imap\Core\Search\Condition
|
||||
*/
|
||||
class From implements Condition
|
||||
{
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
protected $data;
|
||||
|
||||
/**
|
||||
* Class Constructor
|
||||
*
|
||||
* @param string $data
|
||||
*/
|
||||
public function __construct($data)
|
||||
{
|
||||
$this->data = $data;
|
||||
}
|
||||
|
||||
/**
|
||||
* Query String
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function __toString()
|
||||
{
|
||||
return "FROM \"{$this->data}\"";
|
||||
}
|
||||
}
|
||||
42
src/Core/Search/Condition/Keyword.php
Normal file
42
src/Core/Search/Condition/Keyword.php
Normal file
|
|
@ -0,0 +1,42 @@
|
|||
<?php
|
||||
/**
|
||||
* @author clivern <hello@clivern.com>
|
||||
*/
|
||||
|
||||
namespace Clivern\Imap\Core\Search\Condition;
|
||||
|
||||
use Clivern\Imap\Core\Search\Contract\Condition;
|
||||
|
||||
/**
|
||||
* Keyword Class
|
||||
*
|
||||
* @package Clivern\Imap\Core\Search\Condition
|
||||
*/
|
||||
class Keyword implements Condition
|
||||
{
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
protected $data;
|
||||
|
||||
/**
|
||||
* Class Constructor
|
||||
*
|
||||
* @param string $data
|
||||
*/
|
||||
public function __construct($data)
|
||||
{
|
||||
$this->data = $data;
|
||||
}
|
||||
|
||||
/**
|
||||
* Query String
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function __toString()
|
||||
{
|
||||
return "KEYWORD \"{$this->data}\"";
|
||||
}
|
||||
}
|
||||
26
src/Core/Search/Condition/NewFlag.php
Normal file
26
src/Core/Search/Condition/NewFlag.php
Normal file
|
|
@ -0,0 +1,26 @@
|
|||
<?php
|
||||
/**
|
||||
* @author clivern <hello@clivern.com>
|
||||
*/
|
||||
|
||||
namespace Clivern\Imap\Core\Search\Condition;
|
||||
|
||||
use Clivern\Imap\Core\Search\Contract\Condition;
|
||||
|
||||
/**
|
||||
* New Flag Class
|
||||
*
|
||||
* @package Clivern\Imap\Core\Search\Condition
|
||||
*/
|
||||
class NewFlag implements Condition
|
||||
{
|
||||
/**
|
||||
* Query String
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function __toString()
|
||||
{
|
||||
return "NEW";
|
||||
}
|
||||
}
|
||||
26
src/Core/Search/Condition/Old.php
Normal file
26
src/Core/Search/Condition/Old.php
Normal file
|
|
@ -0,0 +1,26 @@
|
|||
<?php
|
||||
/**
|
||||
* @author clivern <hello@clivern.com>
|
||||
*/
|
||||
|
||||
namespace Clivern\Imap\Core\Search\Condition;
|
||||
|
||||
use Clivern\Imap\Core\Search\Contract\Condition;
|
||||
|
||||
/**
|
||||
* Old Class
|
||||
*
|
||||
* @package Clivern\Imap\Core\Search\Condition
|
||||
*/
|
||||
class Old implements Condition
|
||||
{
|
||||
/**
|
||||
* Query String
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function __toString()
|
||||
{
|
||||
return "OLD";
|
||||
}
|
||||
}
|
||||
42
src/Core/Search/Condition/On.php
Normal file
42
src/Core/Search/Condition/On.php
Normal file
|
|
@ -0,0 +1,42 @@
|
|||
<?php
|
||||
/**
|
||||
* @author clivern <hello@clivern.com>
|
||||
*/
|
||||
|
||||
namespace Clivern\Imap\Core\Search\Condition;
|
||||
|
||||
use Clivern\Imap\Core\Search\Contract\Condition;
|
||||
|
||||
/**
|
||||
* On Class
|
||||
*
|
||||
* @package Clivern\Imap\Core\Search\Condition
|
||||
*/
|
||||
class On implements Condition
|
||||
{
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
protected $data;
|
||||
|
||||
/**
|
||||
* Class Constructor
|
||||
*
|
||||
* @param string $data
|
||||
*/
|
||||
public function __construct($data)
|
||||
{
|
||||
$this->data = $data;
|
||||
}
|
||||
|
||||
/**
|
||||
* Query String
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function __toString()
|
||||
{
|
||||
return "ON \"{$this->data}\"";
|
||||
}
|
||||
}
|
||||
26
src/Core/Search/Condition/Recent.php
Normal file
26
src/Core/Search/Condition/Recent.php
Normal file
|
|
@ -0,0 +1,26 @@
|
|||
<?php
|
||||
/**
|
||||
* @author clivern <hello@clivern.com>
|
||||
*/
|
||||
|
||||
namespace Clivern\Imap\Core\Search\Condition;
|
||||
|
||||
use Clivern\Imap\Core\Search\Contract\Condition;
|
||||
|
||||
/**
|
||||
* All Class
|
||||
*
|
||||
* @package Clivern\Imap\Core\Search\Condition
|
||||
*/
|
||||
class Recent implements Condition
|
||||
{
|
||||
/**
|
||||
* Query String
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function __toString()
|
||||
{
|
||||
return "RECENT";
|
||||
}
|
||||
}
|
||||
26
src/Core/Search/Condition/Seen.php
Normal file
26
src/Core/Search/Condition/Seen.php
Normal file
|
|
@ -0,0 +1,26 @@
|
|||
<?php
|
||||
/**
|
||||
* @author clivern <hello@clivern.com>
|
||||
*/
|
||||
|
||||
namespace Clivern\Imap\Core\Search\Condition;
|
||||
|
||||
use Clivern\Imap\Core\Search\Contract\Condition;
|
||||
|
||||
/**
|
||||
* Seen Class
|
||||
*
|
||||
* @package Clivern\Imap\Core\Search\Condition
|
||||
*/
|
||||
class Seen implements Condition
|
||||
{
|
||||
/**
|
||||
* Query String
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function __toString()
|
||||
{
|
||||
return "SEEN";
|
||||
}
|
||||
}
|
||||
42
src/Core/Search/Condition/Since.php
Normal file
42
src/Core/Search/Condition/Since.php
Normal file
|
|
@ -0,0 +1,42 @@
|
|||
<?php
|
||||
/**
|
||||
* @author clivern <hello@clivern.com>
|
||||
*/
|
||||
|
||||
namespace Clivern\Imap\Core\Search\Condition;
|
||||
|
||||
use Clivern\Imap\Core\Search\Contract\Condition;
|
||||
|
||||
/**
|
||||
* Since Class
|
||||
*
|
||||
* @package Clivern\Imap\Core\Search\Condition
|
||||
*/
|
||||
class Since implements Condition
|
||||
{
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
protected $data;
|
||||
|
||||
/**
|
||||
* Class Constructor
|
||||
*
|
||||
* @param string $data
|
||||
*/
|
||||
public function __construct($data)
|
||||
{
|
||||
$this->data = $data;
|
||||
}
|
||||
|
||||
/**
|
||||
* Query String
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function __toString()
|
||||
{
|
||||
return "SINCE \"{$this->data}\"";
|
||||
}
|
||||
}
|
||||
42
src/Core/Search/Condition/Subject.php
Normal file
42
src/Core/Search/Condition/Subject.php
Normal file
|
|
@ -0,0 +1,42 @@
|
|||
<?php
|
||||
/**
|
||||
* @author clivern <hello@clivern.com>
|
||||
*/
|
||||
|
||||
namespace Clivern\Imap\Core\Search\Condition;
|
||||
|
||||
use Clivern\Imap\Core\Search\Contract\Condition;
|
||||
|
||||
/**
|
||||
* Subject Class
|
||||
*
|
||||
* @package Clivern\Imap\Core\Search\Condition
|
||||
*/
|
||||
class Subject implements Condition
|
||||
{
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
protected $data;
|
||||
|
||||
/**
|
||||
* Class Constructor
|
||||
*
|
||||
* @param string $data
|
||||
*/
|
||||
public function __construct($data)
|
||||
{
|
||||
$this->data = $data;
|
||||
}
|
||||
|
||||
/**
|
||||
* Query String
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function __toString()
|
||||
{
|
||||
return "SUBJECT \"{$this->data}\"";
|
||||
}
|
||||
}
|
||||
42
src/Core/Search/Condition/Text.php
Normal file
42
src/Core/Search/Condition/Text.php
Normal file
|
|
@ -0,0 +1,42 @@
|
|||
<?php
|
||||
/**
|
||||
* @author clivern <hello@clivern.com>
|
||||
*/
|
||||
|
||||
namespace Clivern\Imap\Core\Search\Condition;
|
||||
|
||||
use Clivern\Imap\Core\Search\Contract\Condition;
|
||||
|
||||
/**
|
||||
* Text Class
|
||||
*
|
||||
* @package Clivern\Imap\Core\Search\Condition
|
||||
*/
|
||||
class Text implements Condition
|
||||
{
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
protected $data;
|
||||
|
||||
/**
|
||||
* Class Constructor
|
||||
*
|
||||
* @param string $data
|
||||
*/
|
||||
public function __construct($data)
|
||||
{
|
||||
$this->data = $data;
|
||||
}
|
||||
|
||||
/**
|
||||
* Query String
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function __toString()
|
||||
{
|
||||
return "TEXT \"{$this->data}\"";
|
||||
}
|
||||
}
|
||||
42
src/Core/Search/Condition/To.php
Normal file
42
src/Core/Search/Condition/To.php
Normal file
|
|
@ -0,0 +1,42 @@
|
|||
<?php
|
||||
/**
|
||||
* @author clivern <hello@clivern.com>
|
||||
*/
|
||||
|
||||
namespace Clivern\Imap\Core\Search\Condition;
|
||||
|
||||
use Clivern\Imap\Core\Search\Contract\Condition;
|
||||
|
||||
/**
|
||||
* To Class
|
||||
*
|
||||
* @package Clivern\Imap\Core\Search\Condition
|
||||
*/
|
||||
class To implements Condition
|
||||
{
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
protected $data;
|
||||
|
||||
/**
|
||||
* Class Constructor
|
||||
*
|
||||
* @param string $data
|
||||
*/
|
||||
public function __construct($data)
|
||||
{
|
||||
$this->data = $data;
|
||||
}
|
||||
|
||||
/**
|
||||
* Query String
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function __toString()
|
||||
{
|
||||
return "TO \"{$this->data}\"";
|
||||
}
|
||||
}
|
||||
26
src/Core/Search/Condition/UnAnswered.php
Normal file
26
src/Core/Search/Condition/UnAnswered.php
Normal file
|
|
@ -0,0 +1,26 @@
|
|||
<?php
|
||||
/**
|
||||
* @author clivern <hello@clivern.com>
|
||||
*/
|
||||
|
||||
namespace Clivern\Imap\Core\Search\Condition;
|
||||
|
||||
use Clivern\Imap\Core\Search\Contract\Condition;
|
||||
|
||||
/**
|
||||
* UnAnswered Class
|
||||
*
|
||||
* @package Clivern\Imap\Core\Search\Condition
|
||||
*/
|
||||
class UnAnswered implements Condition
|
||||
{
|
||||
/**
|
||||
* Query String
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function __toString()
|
||||
{
|
||||
return "UNANSWERED";
|
||||
}
|
||||
}
|
||||
26
src/Core/Search/Condition/UnDeleted.php
Normal file
26
src/Core/Search/Condition/UnDeleted.php
Normal file
|
|
@ -0,0 +1,26 @@
|
|||
<?php
|
||||
/**
|
||||
* @author clivern <hello@clivern.com>
|
||||
*/
|
||||
|
||||
namespace Clivern\Imap\Core\Search\Condition;
|
||||
|
||||
use Clivern\Imap\Core\Search\Contract\Condition;
|
||||
|
||||
/**
|
||||
* UnDeleted Class
|
||||
*
|
||||
* @package Clivern\Imap\Core\Search\Condition
|
||||
*/
|
||||
class UnDeleted implements Condition
|
||||
{
|
||||
/**
|
||||
* Query String
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function __toString()
|
||||
{
|
||||
return "UNDELETED";
|
||||
}
|
||||
}
|
||||
26
src/Core/Search/Condition/UnFlagged.php
Normal file
26
src/Core/Search/Condition/UnFlagged.php
Normal file
|
|
@ -0,0 +1,26 @@
|
|||
<?php
|
||||
/**
|
||||
* @author clivern <hello@clivern.com>
|
||||
*/
|
||||
|
||||
namespace Clivern\Imap\Core\Search\Condition;
|
||||
|
||||
use Clivern\Imap\Core\Search\Contract\Condition;
|
||||
|
||||
/**
|
||||
* UnFlagged Class
|
||||
*
|
||||
* @package Clivern\Imap\Core\Search\Condition
|
||||
*/
|
||||
class UnFlagged implements Condition
|
||||
{
|
||||
/**
|
||||
* Query String
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function __toString()
|
||||
{
|
||||
return "UNFLAGGED";
|
||||
}
|
||||
}
|
||||
42
src/Core/Search/Condition/UnKeyword.php
Normal file
42
src/Core/Search/Condition/UnKeyword.php
Normal file
|
|
@ -0,0 +1,42 @@
|
|||
<?php
|
||||
/**
|
||||
* @author clivern <hello@clivern.com>
|
||||
*/
|
||||
|
||||
namespace Clivern\Imap\Core\Search\Condition;
|
||||
|
||||
use Clivern\Imap\Core\Search\Contract\Condition;
|
||||
|
||||
/**
|
||||
* UnKeyword Class
|
||||
*
|
||||
* @package Clivern\Imap\Core\Search\Condition
|
||||
*/
|
||||
class UnKeyword implements Condition
|
||||
{
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
protected $data;
|
||||
|
||||
/**
|
||||
* Class Constructor
|
||||
*
|
||||
* @param string $data
|
||||
*/
|
||||
public function __construct($data)
|
||||
{
|
||||
$this->data = $data;
|
||||
}
|
||||
|
||||
/**
|
||||
* Query String
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function __toString()
|
||||
{
|
||||
return "UNKEYWORD \"{$this->data}\"";
|
||||
}
|
||||
}
|
||||
26
src/Core/Search/Condition/UnSeen.php
Normal file
26
src/Core/Search/Condition/UnSeen.php
Normal file
|
|
@ -0,0 +1,26 @@
|
|||
<?php
|
||||
/**
|
||||
* @author clivern <hello@clivern.com>
|
||||
*/
|
||||
|
||||
namespace Clivern\Imap\Core\Search\Condition;
|
||||
|
||||
use Clivern\Imap\Core\Search\Contract\Condition;
|
||||
|
||||
/**
|
||||
* UnSeen Class
|
||||
*
|
||||
* @package Clivern\Imap\Core\Search\Condition
|
||||
*/
|
||||
class UnSeen implements Condition
|
||||
{
|
||||
/**
|
||||
* Query String
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function __toString()
|
||||
{
|
||||
return "UNSEEN";
|
||||
}
|
||||
}
|
||||
16
src/Core/Search/Contract/Condition.php
Normal file
16
src/Core/Search/Contract/Condition.php
Normal file
|
|
@ -0,0 +1,16 @@
|
|||
<?php
|
||||
/**
|
||||
* @author clivern <hello@clivern.com>
|
||||
*/
|
||||
|
||||
namespace Clivern\Imap\Core\Search\Contract;
|
||||
|
||||
/**
|
||||
* Condition Interface
|
||||
*
|
||||
* @package Clivern\Imap\Core\Search\Contract
|
||||
*/
|
||||
interface Condition
|
||||
{
|
||||
public function __toString();
|
||||
}
|
||||
|
|
@ -75,7 +75,7 @@ class MailBox
|
|||
* Get message ids
|
||||
*
|
||||
* @param Search $search
|
||||
* @return MessageIterator|Message[]
|
||||
* @return MessageIterator
|
||||
*/
|
||||
public function getMessages(Search $search = null)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -8,12 +8,14 @@ class SearchTest extends TestCase
|
|||
public function testConditionBuilder()
|
||||
{
|
||||
$search = new \Clivern\Imap\Core\Search();
|
||||
$search->addCondition('RECENT')->addCondition('BCC "string"')->addCondition('NEW');
|
||||
$search->addCondition(new \Clivern\Imap\Core\Search\Condition\To("hello@clivern.com"))
|
||||
->addCondition(new \Clivern\Imap\Core\Search\Condition\BCC("hello@clivern.com"))
|
||||
->addCondition(new \Clivern\Imap\Core\Search\Condition\NewFlag());
|
||||
$this->assertEquals($search->getConditions(), [
|
||||
'RECENT',
|
||||
'BCC "string"',
|
||||
'TO "hello@clivern.com"',
|
||||
'BCC "hello@clivern.com"',
|
||||
'NEW'
|
||||
]);
|
||||
$this->assertEquals((string) $search, 'RECENT BCC "string" NEW');
|
||||
$this->assertEquals((string) $search, 'TO "hello@clivern.com" BCC "hello@clivern.com" NEW');
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue