/** * The second case which used PHP native functions is volontary limited by the native functions provided by PHP, * and the possible types defined in xsd_types.yml * @param StructAttributeModel $attribute * @param string $itemName * @return string */ protected function getItemSanityCheck(StructAttribute $attribute, $itemName) { $model = $this->getFile()->getModelFromStructAttribute($attribute); $sanityCheck = 'false'; if ($model instanceof Struct && ($model->getIsStruct() || $model->isArray() && $model->getInheritanceStruct() instanceof Struct)) { $sanityCheck = sprintf('$%s instanceof %s', $itemName, $this->getFile()->getStructAttributeType($attribute, true)); } else { switch (AbstractModelFile::getPhpType($attribute->getType())) { case 'int': $sanityCheck = 'is_int($%s)'; break; case 'bool': $sanityCheck = 'is_bool($%s)'; break; case 'float': $sanityCheck = 'is_float($%s)'; break; case 'string': $sanityCheck = 'is_string($%s)'; break; } $sanityCheck = sprintf($sanityCheck, $itemName); } return $sanityCheck; }
/** * @see \WsdlToPhp\PackageGenerator\File\AbstractModelFile::setModel() * @throws \InvalidaArgumentException * @param AbstractModel $model * @return Service */ public function setModel(AbstractModel $model) { if (!$model instanceof ServiceModel) { throw new \InvalidArgumentException('Model must be an instance of a Service', __LINE__); } return parent::setModel($model); }