-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #13 from josaphatim/added-actions
Added missing actions
- Loading branch information
Showing
7 changed files
with
220 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
<?php | ||
|
||
namespace PhpSieveManager\Filters\Actions; | ||
|
||
use PhpSieveManager\Exceptions\FilterActionParamException; | ||
|
||
/** | ||
* Please refer to https://datatracker.ietf.org/doc/html/rfc5293#section-4 | ||
*/ | ||
class AddHeaderFilterAction implements FilterAction | ||
{ | ||
private $params; | ||
|
||
/** | ||
* @param array $params | ||
* @throws FilterActionParamException | ||
*/ | ||
public function __construct(array $params = []) { | ||
if (count($params) != 2) { | ||
throw new FilterActionParamException("AddHeaderFilterAction expect two parameters"); | ||
} | ||
$this->params = $params; | ||
} | ||
|
||
/** | ||
* @return string | ||
*/ | ||
public function parse() { | ||
return 'addheader "'.$this->params[0].'" "'.$this->params[1].'";'."\n"; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
<?php | ||
|
||
namespace PhpSieveManager\Filters\Actions; | ||
|
||
use PhpSieveManager\Exceptions\FilterActionParamException; | ||
|
||
/** | ||
* Please refer to https://www.rfc-editor.org/rfc/rfc6558.html | ||
*/ | ||
class ConvertFilterAction implements FilterAction | ||
{ | ||
private $params; | ||
|
||
/** | ||
* @param array $params | ||
* @throws FilterActionParamException | ||
*/ | ||
public function __construct(array $params = []) { | ||
if (count($params) != 3) { | ||
throw new FilterActionParamException("ConvertFilterAction expect three parameters"); | ||
} | ||
$this->params = $params; | ||
} | ||
|
||
/** | ||
* @return string | ||
*/ | ||
public function parse() { | ||
return 'convert "'.$this->params[0].'" "'.$this->params[1].'" ["'.implode('","', $this->params[2]).'"];'."\n"; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
<?php | ||
|
||
namespace PhpSieveManager\Filters\Actions; | ||
|
||
use PhpSieveManager\Exceptions\FilterActionParamException; | ||
|
||
/** | ||
* Please refer to https://datatracker.ietf.org/doc/html/rfc5293#section-5 | ||
*/ | ||
class DeleteHeaderFilterAction implements FilterAction | ||
{ | ||
private $params; | ||
|
||
/** | ||
* @param array $params | ||
* @throws FilterActionParamException | ||
*/ | ||
public function __construct(array $params = []) { | ||
if (count($params) != 1) { | ||
throw new FilterActionParamException("DeleteHeaderFilterAction expect one parameters"); | ||
} | ||
$this->params = $params; | ||
} | ||
|
||
/** | ||
* @return string | ||
*/ | ||
public function parse() { | ||
return 'deleteheader "'.$this->params[0].'";'."\n"; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
<?php | ||
|
||
namespace PhpSieveManager\Filters\Actions; | ||
|
||
use PhpSieveManager\Exceptions\FilterActionParamException; | ||
|
||
/** | ||
* Please refer to https://www.rfc-editor.org/rfc/rfc5703.html#section-6 | ||
*/ | ||
class EncloseFilterAction implements FilterAction | ||
{ | ||
private $params; | ||
|
||
/** | ||
* @param array $params | ||
* @throws FilterActionParamException | ||
*/ | ||
public function __construct(array $params = []) { | ||
if (count($params) != 1) { | ||
throw new FilterActionParamException("EncloseFilterAction expect one parameters"); | ||
} | ||
$this->params = $params; | ||
} | ||
|
||
/** | ||
* @return string | ||
*/ | ||
public function parse() { | ||
return 'enclose "'.$this->params[0].'";'."\n"; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
<?php | ||
|
||
namespace PhpSieveManager\Filters\Actions; | ||
|
||
use PhpSieveManager\Exceptions\FilterActionParamException; | ||
|
||
/** | ||
* Please refer to https://www.rfc-editor.org/rfc/rfc5703.html#page-11 | ||
*/ | ||
class ExtractTextFilterAction implements FilterAction | ||
{ | ||
private $params; | ||
|
||
/** | ||
* @param array $params | ||
* @throws FilterActionParamException | ||
*/ | ||
public function __construct(array $params = []) { | ||
if ($params && count($params) > 2) { | ||
throw new FilterActionParamException("ExtractTextFilterAction expect one or two parameters"); | ||
} | ||
$this->params = $params; | ||
} | ||
|
||
/** | ||
* @return string | ||
*/ | ||
public function parse() { | ||
if (count($this->params) == 1) { | ||
return 'extracttext "'.$this->params[0].'";'."\n"; | ||
} | ||
return 'extracttext :first '.$this->params[0].' "'.$this->params[1].'";'."\n"; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
<?php | ||
|
||
namespace PhpSieveManager\Filters\Actions; | ||
|
||
use PhpSieveManager\Exceptions\FilterActionParamException; | ||
|
||
/** | ||
* Please refer to https://datatracker.ietf.org/doc/rfc5435/ | ||
*/ | ||
class NotifyFilterAction implements FilterAction | ||
{ | ||
private $params; | ||
|
||
/** | ||
* @param array $params | ||
* @throws FilterActionParamException | ||
*/ | ||
public function __construct(array $params = []) { | ||
if (count($params) != 3) { | ||
throw new FilterActionParamException("NotifyFilterAction expect three parameters"); | ||
} | ||
$this->params = $params; | ||
} | ||
|
||
/** | ||
* @return string | ||
*/ | ||
public function parse() { | ||
return 'notify :importance "'.$this->params[0].'" :text "'.$this->params[1].'" "'.$this->params[2].'";'."\n"; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
<?php | ||
|
||
namespace PhpSieveManager\Filters\Actions; | ||
|
||
use PhpSieveManager\Exceptions\FilterActionParamException; | ||
|
||
/** | ||
* Please refer to https://www.rfc-editor.org/rfc/rfc5229.html | ||
*/ | ||
class SetFilterAction implements FilterAction | ||
{ | ||
private $params; | ||
|
||
/** | ||
* @param array $params | ||
* @throws FilterActionParamException | ||
*/ | ||
public function __construct(array $params = []) { | ||
if (count($params) != 2) { | ||
throw new FilterActionParamException("SetFilterAction expect two parameters"); | ||
} | ||
$this->params = $params; | ||
} | ||
|
||
/** | ||
* @return string | ||
*/ | ||
public function parse() { | ||
return 'set "'.$this->params[0].'" "'.$this->params[1].'";'."\n"; | ||
} | ||
} |