Exemple #1
0
 public function __construct(ParsedInput $valid)
 {
     if (!$valid->isValidated()) {
         throw new BadMethodCallException();
     }
     $this->setData($valid->getData());
 }
Exemple #2
0
 /**
  * @param array data to add
  * @return this
  * @throws BadMethodCallException
  */
 public function addData(ParsedInput $add) : self
 {
     if ($this->isValidated()) {
         throw new BadMethodCallException("Data cannot be added after validation is performed");
     }
     if ($add->isValidated()) {
         throw new BadMethodCallException("Data cannot be added after validation is performed");
     }
     $this->setData(array_merge($add->getData(), $this->getData()));
     return $this;
 }
Exemple #3
0
 protected function validate($value) : bool
 {
     if (!is_array($value)) {
         return false;
     }
     $parsed = new ParsedInput($value);
     try {
         $this->validated = $parsed->validate($this);
         return true;
     } catch (InputException $e) {
         return false;
     }
 }
Exemple #4
0
 /**
  * @covers ::validate
  */
 public function testMissingOptionalParametersAreSetToNull()
 {
     $this->addOptional('short', $this->getMockForAbstractClass('Firehed\\Input\\Objects\\InputObject'));
     $parsed = new ParsedInput([]);
     $ret = $parsed->validate($this->getValidation());
     $this->assertInstanceOf('Firehed\\Input\\Containers\\SafeInput', $ret);
     $this->assertNull($ret['short'], "'short' should have defaulted to null");
 }