public function createProperty($name, $value = null, array $parameters = null, $valueType = null)
    {
        // If there's a . in the name, it means it's prefixed by a groupname.
        if (false !== ($i = strpos($name, '.'))) {
            $group = substr($name, 0, $i);
            $name = strtoupper(substr($name, $i + 1));
        } else {
            $name = strtoupper($name);
            $group = null;
        }

        $class = null;

        if ($valueType) {
            // The valueType argument comes first to figure out the correct
            // class.
            $class = $this->getClassNameForPropertyValue($valueType);
        }

        if (is_null($class)) {
            // If a VALUE parameter is supplied, we should use that.
            if (isset($parameters['VALUE'])) {
                $class = $this->getClassNameForPropertyValue($parameters['VALUE']);
                if (is_null($class)) {
                    throw new InvalidDataException('Unsupported VALUE parameter for '.$name.' property. You supplied "'.$parameters['VALUE'].'"');
                }
            } else {
                $class = $this->getClassNameForPropertyName($name);
            }
        }
        if (is_null($parameters)) {
            $parameters = [];
        }

        return new $class($this, $name, $value, $parameters, $group);
    }
public function createProperty($name, $value = null, array $parameters = null, $valueType = null)
    {
        // If there's a . in the name, it means it's prefixed by a groupname.
        if (false !== ($i = strpos($name, '.'))) {
            $group = substr($name, 0, $i);
            $name = strtoupper(substr($name, $i + 1));
        } else {
            $name = strtoupper($name);
            $group = null;
        }

        $class = null;

        if ($valueType) {
            // The valueType argument comes first to figure out the correct
            // class.
            $class = $this->getClassNameForPropertyValue($valueType);
        }

        if (is_null($class)) {
            // If a VALUE parameter is supplied, we should use that.
            if (isset($parameters['VALUE'])) {
                $class = $this->getClassNameForPropertyValue($parameters['VALUE']);
                if (is_null($class)) {
                    throw new InvalidDataException('Unsupported VALUE parameter for '.$name.' property. You supplied "'.$parameters['VALUE'].'"');
                }
            } else {
                $class = $this->getClassNameForPropertyName($name);
            }
        }
        if (is_null($parameters)) {
            $parameters = [];
        }

        return new $class($this, $name, $value, $parameters, $group);
    }
public function createProperty ( $ name , $ value = null , array $ parameters = null , $ valueType = null ) { // If there's a . in the name, it means it's prefixed by a groupname. if ( false !== ( $ i = strpos ( $ name , '.' ) ) ) { $ group = substr ( $ name , 0 , $ i ) ; $ name = strtoupper ( substr ( $ name , $ i + 1 ) ) ; } else { $ name = strtoupper ( $ name ) ; $ group = null ; } $ class = null ; if ( $ valueType ) { // The valueType argument comes first to figure out the correct // class. $ class = $ this -> getClassNameForPropertyValue ( $ valueType ) ; } if ( is_null ( $ class ) ) { // If a VALUE parameter is supplied, we should use that. if ( isset ( $ parameters [ 'VALUE' ] ) ) { $ class = $ this -> getClassNameForPropertyValue ( $ parameters [ 'VALUE' ] ) ; if ( is_null ( $ class ) ) { throw new InvalidDataException ( 'Unsupported VALUE parameter for ' . $ name . ' property. You supplied "' . $ parameters [ 'VALUE' ] . '"' ) ; } } else { $ class = $ this -> getClassNameForPropertyName ( $ name ) ; } } if ( is_null ( $ parameters ) ) { $ parameters = [ ] ; } return new $ class ( $ this , $ name , $ value , $ parameters , $ group ) ; }
Factory method for creating new properties.

This method automatically searches for the correct property class, based
on its name.

You can specify the parameters either in key=>value syntax, in which case
parameters will automatically be created, or you can just pass a list of
Parameter objects.

@param string $name
@param mixed  $value
@param array  $parameters
@param string $valueType  Force a specific valuetype, such as URI or TEXT

@return Property
Factory method for creating new properties .