Skip to content

Commit 9262e35

Browse files
committed
Added missing actions
1 parent dbed4e5 commit 9262e35

File tree

7 files changed

+220
-0
lines changed

7 files changed

+220
-0
lines changed
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
<?php
2+
3+
namespace PhpSieveManager\Filters\Actions;
4+
5+
use PhpSieveManager\Exceptions\FilterActionParamException;
6+
7+
/**
8+
* Please refer to https://datatracker.ietf.org/doc/html/rfc5293#section-4
9+
*/
10+
class AddHeaderFilterAction implements FilterAction
11+
{
12+
private $params;
13+
14+
/**
15+
* @param array $params
16+
* @throws FilterActionParamException
17+
*/
18+
public function __construct(array $params = []) {
19+
if (count($params) != 2) {
20+
throw new FilterActionParamException("AddHeaderFilterAction expect two parameters");
21+
}
22+
$this->params = $params;
23+
}
24+
25+
/**
26+
* @return string
27+
*/
28+
public function parse() {
29+
return 'addheader "'.$this->params[0].'" "'.$this->params[1].'";'."\n";
30+
}
31+
}
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
<?php
2+
3+
namespace PhpSieveManager\Filters\Actions;
4+
5+
use PhpSieveManager\Exceptions\FilterActionParamException;
6+
7+
/**
8+
* Please refer to https://www.rfc-editor.org/rfc/rfc6558.html
9+
*/
10+
class ConvertFilterAction implements FilterAction
11+
{
12+
private $params;
13+
14+
/**
15+
* @param array $params
16+
* @throws FilterActionParamException
17+
*/
18+
public function __construct(array $params = []) {
19+
if (count($params) != 3) {
20+
throw new FilterActionParamException("ConvertFilterAction expect three parameters");
21+
}
22+
$this->params = $params;
23+
}
24+
25+
/**
26+
* @return string
27+
*/
28+
public function parse() {
29+
return 'convert "'.$this->params[0].'" "'.$this->params[1].'" ["'.implode('","', $this->params[2]).'"];'."\n";
30+
}
31+
}
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
<?php
2+
3+
namespace PhpSieveManager\Filters\Actions;
4+
5+
use PhpSieveManager\Exceptions\FilterActionParamException;
6+
7+
/**
8+
* Please refer to https://datatracker.ietf.org/doc/html/rfc5293#section-5
9+
*/
10+
class DeleteHeaderFilterAction implements FilterAction
11+
{
12+
private $params;
13+
14+
/**
15+
* @param array $params
16+
* @throws FilterActionParamException
17+
*/
18+
public function __construct(array $params = []) {
19+
if (count($params) != 1) {
20+
throw new FilterActionParamException("DeleteHeaderFilterAction expect one parameters");
21+
}
22+
$this->params = $params;
23+
}
24+
25+
/**
26+
* @return string
27+
*/
28+
public function parse() {
29+
return 'deleteheader "'.$this->params[0].'";'."\n";
30+
}
31+
}
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
<?php
2+
3+
namespace PhpSieveManager\Filters\Actions;
4+
5+
use PhpSieveManager\Exceptions\FilterActionParamException;
6+
7+
/**
8+
* Please refer to https://www.rfc-editor.org/rfc/rfc5703.html#section-6
9+
*/
10+
class EncloseFilterAction implements FilterAction
11+
{
12+
private $params;
13+
14+
/**
15+
* @param array $params
16+
* @throws FilterActionParamException
17+
*/
18+
public function __construct(array $params = []) {
19+
if (count($params) != 1) {
20+
throw new FilterActionParamException("EncloseFilterAction expect one parameters");
21+
}
22+
$this->params = $params;
23+
}
24+
25+
/**
26+
* @return string
27+
*/
28+
public function parse() {
29+
return 'enclose "'.$this->params[0].'";'."\n";
30+
}
31+
}
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
<?php
2+
3+
namespace PhpSieveManager\Filters\Actions;
4+
5+
use PhpSieveManager\Exceptions\FilterActionParamException;
6+
7+
/**
8+
* Please refer to https://www.rfc-editor.org/rfc/rfc5703.html#page-11
9+
*/
10+
class ExtractTextFilterAction implements FilterAction
11+
{
12+
private $params;
13+
14+
/**
15+
* @param array $params
16+
* @throws FilterActionParamException
17+
*/
18+
public function __construct(array $params = []) {
19+
if ($params && count($params) > 2) {
20+
throw new FilterActionParamException("ExtractTextFilterAction expect one or two parameters");
21+
}
22+
$this->params = $params;
23+
}
24+
25+
/**
26+
* @return string
27+
*/
28+
public function parse() {
29+
if (count($this->params) == 1) {
30+
return 'extracttext "'.$this->params[0].'";'."\n";
31+
}
32+
return 'extracttext :first '.$this->params[0].' "'.$this->params[1].'";'."\n";
33+
}
34+
}
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
<?php
2+
3+
namespace PhpSieveManager\Filters\Actions;
4+
5+
use PhpSieveManager\Exceptions\FilterActionParamException;
6+
7+
/**
8+
* Please refer to https://datatracker.ietf.org/doc/rfc5435/
9+
*/
10+
class NotifyFilterAction implements FilterAction
11+
{
12+
private $params;
13+
14+
/**
15+
* @param array $params
16+
* @throws FilterActionParamException
17+
*/
18+
public function __construct(array $params = []) {
19+
if (count($params) != 3) {
20+
throw new FilterActionParamException("NotifyFilterAction expect three parameters");
21+
}
22+
$this->params = $params;
23+
}
24+
25+
/**
26+
* @return string
27+
*/
28+
public function parse() {
29+
return 'notify :importance "'.$this->params[0].'" :text "'.$this->params[1].'" "'.$this->params[2].'";'."\n";
30+
}
31+
}
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
<?php
2+
3+
namespace PhpSieveManager\Filters\Actions;
4+
5+
use PhpSieveManager\Exceptions\FilterActionParamException;
6+
7+
/**
8+
* Please refer to https://www.rfc-editor.org/rfc/rfc5229.html
9+
*/
10+
class SetFilterAction implements FilterAction
11+
{
12+
private $params;
13+
14+
/**
15+
* @param array $params
16+
* @throws FilterActionParamException
17+
*/
18+
public function __construct(array $params = []) {
19+
if (count($params) != 2) {
20+
throw new FilterActionParamException("SetFilterAction expect two parameters");
21+
}
22+
$this->params = $params;
23+
}
24+
25+
/**
26+
* @return string
27+
*/
28+
public function parse() {
29+
return 'set "'.$this->params[0].'" "'.$this->params[1].'";'."\n";
30+
}
31+
}

0 commit comments

Comments
 (0)