1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59
|
<?php
/**
* Copyright 2013-2017 Horde LLC (http://www.horde.org/)
*
* See the enclosed file LICENSE for license information (ASL). If you
* did not receive this file, see http://www.horde.org/licenses/apache.
*
* @author Jan Schneider <jan@horde.org>
* @category Horde
* @license http://www.horde.org/licenses/apache ASL
* @package Ingo
*/
/**
* The Ingo_Script_Sieve_Require class represents a Sieve Require statement.
*
* @author Jan Schneider <jan@horde.org>
* @category Horde
* @license http://www.horde.org/licenses/apache ASL
* @package Ingo
*/
class Ingo_Script_Sieve_Require implements Ingo_Script_Item
{
/**
* @var array
*/
protected $_requires;
/**
* Constructor.
*
* @param array $requires The required extensions.
*/
public function __construct(array $requires)
{
$this->_requires = $requires;
}
/**
* Returns a script snippet representing this rule.
*
* @return string A Sieve script snippet.
*/
public function generate()
{
if (count($this->_requires) > 1) {
$stringlist = '';
foreach ($this->_requires as $require) {
$stringlist .= (empty($stringlist)) ? '"' : ', "';
$stringlist .= $require . '"';
}
return 'require [' . $stringlist . '];';
}
if (count($this->_requires) == 1) {
return 'require "' . $this->_requires[0] . '";';
}
return '';
}
}
|