WsdlToPhp\PackageGenerator\Model\AbstractModel::addMeta PHP Method

addMeta() public method

Add meta information to the operation
public addMeta ( string $metaName, mixed $metaValue ) : AbstractModel
$metaName string
$metaValue mixed
return AbstractModel
    public function addMeta($metaName, $metaValue)
    {
        if (!is_scalar($metaName) || !is_scalar($metaValue) && !is_array($metaValue)) {
            throw new \InvalidArgumentException(sprintf('Invalid meta name "%s" or value "%s". Please provide scalar meta name and scalar or array meta value.', gettype($metaName), gettype($metaValue)), __LINE__);
        }
        $metaValue = is_scalar($metaValue) ? trim($metaValue) : $metaValue;
        if (is_scalar($metaValue) && $metaValue !== '' || is_array($metaValue)) {
            if (!array_key_exists($metaName, $this->meta)) {
                $this->meta[$metaName] = $metaValue;
            } elseif (is_array($this->meta[$metaName]) && is_array($metaValue)) {
                $this->meta[$metaName] = array_merge($this->meta[$metaName], $metaValue);
            } elseif (is_array($this->meta[$metaName])) {
                array_push($this->meta[$metaName], $metaValue);
            } else {
                $this->meta[$metaName] = $metaValue;
            }
            ksort($this->meta);
        }
        return $this;
    }

Usage Example

 /**
  * Enumeration does not need its own value as meta information, it's like the name for struct attribute
  * @param AttributeHandler $tagAttribute
  * @param AbstractModel $model
  */
 protected function parseTagAttributeValue(AttributeHandler $tagAttribute, AbstractModel $model)
 {
     if (!$model instanceof StructValue) {
         $model->addMeta($tagAttribute->getName(), $tagAttribute->getValue(true));
     }
 }