Predis\Configuration\ReplicationOption::filter PHP Метод

filter() публичный Метод

public filter ( Predis\Configuration\OptionsInterface $options, $value )
$options Predis\Configuration\OptionsInterface
    public function filter(OptionsInterface $options, $value)
    {
        if ($value instanceof ReplicationInterface) {
            return $value;
        }
        if (is_bool($value) || $value === null) {
            return $value ? $this->getDefault($options) : null;
        }
        if ($value === 'sentinel') {
            return function ($sentinels, $options) {
                return new SentinelReplication($options->service, $sentinels, $options->connections);
            };
        }
        if (!is_object($value) && null !== ($asbool = filter_var($value, FILTER_VALIDATE_BOOLEAN, FILTER_NULL_ON_FAILURE))) {
            return $asbool ? $this->getDefault($options) : null;
        }
        throw new \InvalidArgumentException("An instance of type 'Predis\\Connection\\Aggregate\\ReplicationInterface' was expected.");
    }

Usage Example

 /**
  * @group disconnected
  * @expectedException \InvalidArgumentException
  */
 public function testThrowsExceptionOnInvalidInstanceType()
 {
     $option = new ReplicationOption();
     $options = $this->getMock('Predis\\Configuration\\OptionsInterface');
     $value = $this->getMock('Predis\\Connection\\NodeConnectionInterface');
     $option->filter($options, $value);
 }
ReplicationOption