コード例 #1
0
ファイル: ScalarNode.php プロジェクト: nuxwin/i-PMS
 /**
  * {@inheritDoc}
  */
 protected function validateType($value)
 {
     if (!is_scalar($value) && null !== $value) {
         $ex = new InvalidTypeException(sprintf('Invalid type for path "%s". Expected scalar, but got %s.', $this->getPath(), gettype($value)));
         $ex->setPath($this->getPath());
         throw $ex;
     }
 }
コード例 #2
0
 /**
  * {@inheritdoc}
  */
 protected function validateType($value)
 {
     if (!is_bool($value)) {
         $ex = new InvalidTypeException(sprintf('Invalid type for path "%s". Expected boolean, but got %s.', $this->getPath(), gettype($value)));
         $ex->setPath($this->getPath());
         throw $ex;
     }
 }
コード例 #3
0
 /**
  * {@inheritdoc}
  */
 protected function validateType($value)
 {
     if (!is_array($value)) {
         $ex = new InvalidTypeException(sprintf('Invalid type for path "%s". Expected array, but got %s', $this->getPath(), gettype($value)));
         if ($hint = $this->getInfo()) {
             $ex->addHint($hint);
         }
         $ex->setPath($this->getPath());
         throw $ex;
     }
 }
コード例 #4
0
 /**
  * Validates the type of a Node.
  *
  * @param mixed $value The value to validate
  *
  * @throws InvalidTypeException when the value is invalid
  */
 protected function validateType($value)
 {
     if (!$value instanceof Closure && $value !== null) {
         $exception = new InvalidTypeException(sprintf('Invalid type for path "%s". Expected closure, but got %s.', $this->getPath(), gettype($value)));
         if ($hint = $this->getInfo()) {
             $exception->addHint($hint);
         }
         $exception->setPath($this->getPath());
         throw $exception;
     }
 }
コード例 #5
0
ファイル: FloatNode.php プロジェクト: ccq18/EduSoho
 /**
  * {@inheritdoc}
  */
 protected function validateType($value)
 {
     // Integers are also accepted, we just cast them
     if (is_int($value)) {
         $value = (double) $value;
     }
     if (!is_float($value)) {
         $ex = new InvalidTypeException(sprintf('Invalid type for path "%s". Expected float, but got %s.', $this->getPath(), gettype($value)));
         $ex->setPath($this->getPath());
         throw $ex;
     }
 }
コード例 #6
0
ファイル: FloatNode.php プロジェクト: Ryu0621/SaNaVi
 protected function validateType($value)
 {
     if (is_int($value)) {
         $value = (double) $value;
     }
     if (!is_float($value)) {
         $ex = new InvalidTypeException(sprintf('Invalid type for path "%s". Expected float, but got %s.', $this->getPath(), gettype($value)));
         if ($hint = $this->getInfo()) {
             $ex->addHint($hint);
         }
         $ex->setPath($this->getPath());
         throw $ex;
     }
 }
コード例 #7
0
 /**
  * Validates the type of the value.
  *
  * @param mixed $value
  *
  * @throws InvalidTypeException
  */
 protected function validateType($value)
 {
     if (!is_array($value) && (!$this->allowFalse || false !== $value)) {
         $ex = new InvalidTypeException(sprintf('Invalid type for path "%s". Expected array, but got %s', $this->getPath(), gettype($value)));
         $ex->setPath($this->getPath());
         throw $ex;
     }
 }