Author: Jakub Tománek
Exemplo n.º 1
0
Arquivo: Fluent.php Projeto: jyxo/php
 /**
  * Adds a conditional chain.
  *
  * If there are conditions in the current chain, adds the condition as a subchain.
  *
  * @param string $name Validator name
  * @param mixed $param Additional validator parameter
  * @return \Jyxo\Input\Fluent
  * @throws \BadMethodCallException There is no active variable
  */
 public function condition(string $name, $param = null) : self
 {
     $condChain = new Chain\Conditional($this->factory->getValidatorByName($name, $param));
     if (true === $this->chain->isEmpty()) {
         // The actual chain is empty, can be replaced by the condition
         $this->chain = $condChain;
         if (null === $this->currentName) {
             throw new \BadMethodCallException('No active variable');
         }
         $this->chains[$this->currentName] = $condChain;
     } else {
         $this->chain = $this->chain->addCondition($condChain);
     }
     return $this;
 }
Exemplo n.º 2
0
 /**
  * Tests creating a non-existent filter.
  */
 public function testInexistentValidator()
 {
     $this->expectException(\Jyxo\Input\Exception::class);
     $this->factory->getValidatorByName('foo');
 }
Exemplo n.º 3
0
 /**
  * Tests creating a non-existent filter.
  */
 public function testInexistentValidator()
 {
     $this->setExpectedException('\\Jyxo\\Input\\Exception');
     $this->factory->getValidatorByName('foo');
 }