public static function createFromArray($key, array $data = [])
    {
        $namedParameter = new static($key);

        if (isset($data['displayName'])) {
            $namedParameter->setDisplayName($data['displayName']);
        }

        if (isset($data['description'])) {
            $namedParameter->setDescription($data['description']);
        }

        if (isset($data['type'])) {
            $namedParameter->setType($data['type']);
        }

        if (isset($data['enum'])) {
            $namedParameter->setEnum($data['enum']);
        }

        if (isset($data['pattern'])) {
            $namedParameter->setValidationPattern($data['pattern']);
        }

        // RAML 1.0
        if (isset($data['validationPattern'])) {
            $namedParameter->setValidationPattern($data['validationPattern']);
        }

        if (isset($data['minLength'])) {
            $namedParameter->setMinLength($data['minLength']);
        }

        if (isset($data['maxLength'])) {
            $namedParameter->setMaxLength($data['maxLength']);
        }

        if (isset($data['minimum'])) {
            $namedParameter->setMinimum($data['minimum']);
        }

        if (isset($data['maximum'])) {
            $namedParameter->setMaximum($data['maximum']);
        }

        if (isset($data['example'])) {
            $namedParameter->addExample($data['example']);
        }

        if (isset($data['examples'])) {
            foreach ($data['examples'] as $example) {
                $namedParameter->addExample($example);
            }
        }

        if (isset($data['repeat'])) {
            $namedParameter->setRepeat($data['repeat']);
        }

        if (isset($data['required'])) {
            $namedParameter->setRequired($data['required']);
        }

        if (isset($data['default'])) {
            if ($namedParameter->getType() === self::TYPE_DATE) {
                $namedParameter->setDefault(\DateTimeImmutable::createFromFormat('D, d M Y H:i:s T', $data['default']));
            } else {
                $namedParameter->setDefault($data['default']);
            }
        }

        if (isset($data['format'])) {
            $namedParameter->setFormat($data['format']);
        }

        return $namedParameter;
    }
public static function createFromArray($key, array $data = [])
    {
        $namedParameter = new static($key);

        if (isset($data['displayName'])) {
            $namedParameter->setDisplayName($data['displayName']);
        }

        if (isset($data['description'])) {
            $namedParameter->setDescription($data['description']);
        }

        if (isset($data['type'])) {
            $namedParameter->setType($data['type']);
        }

        if (isset($data['enum'])) {
            $namedParameter->setEnum($data['enum']);
        }

        if (isset($data['pattern'])) {
            $namedParameter->setValidationPattern($data['pattern']);
        }

        // RAML 1.0
        if (isset($data['validationPattern'])) {
            $namedParameter->setValidationPattern($data['validationPattern']);
        }

        if (isset($data['minLength'])) {
            $namedParameter->setMinLength($data['minLength']);
        }

        if (isset($data['maxLength'])) {
            $namedParameter->setMaxLength($data['maxLength']);
        }

        if (isset($data['minimum'])) {
            $namedParameter->setMinimum($data['minimum']);
        }

        if (isset($data['maximum'])) {
            $namedParameter->setMaximum($data['maximum']);
        }

        if (isset($data['example'])) {
            $namedParameter->addExample($data['example']);
        }

        if (isset($data['examples'])) {
            foreach ($data['examples'] as $example) {
                $namedParameter->addExample($example);
            }
        }

        if (isset($data['repeat'])) {
            $namedParameter->setRepeat($data['repeat']);
        }

        if (isset($data['required'])) {
            $namedParameter->setRequired($data['required']);
        }

        if (isset($data['default'])) {
            if ($namedParameter->getType() === self::TYPE_DATE) {
                $namedParameter->setDefault(\DateTimeImmutable::createFromFormat('D, d M Y H:i:s T', $data['default']));
            } else {
                $namedParameter->setDefault($data['default']);
            }
        }

        if (isset($data['format'])) {
            $namedParameter->setFormat($data['format']);
        }

        return $namedParameter;
    }
public static function createFromArray ( $ key , array $ data = [ ] ) { $ namedParameter = new static ( $ key ) ; if ( isset ( $ data [ 'displayName' ] ) ) { $ namedParameter -> setDisplayName ( $ data [ 'displayName' ] ) ; } if ( isset ( $ data [ 'description' ] ) ) { $ namedParameter -> setDescription ( $ data [ 'description' ] ) ; } if ( isset ( $ data [ 'type' ] ) ) { $ namedParameter -> setType ( $ data [ 'type' ] ) ; } if ( isset ( $ data [ 'enum' ] ) ) { $ namedParameter -> setEnum ( $ data [ 'enum' ] ) ; } if ( isset ( $ data [ 'pattern' ] ) ) { $ namedParameter -> setValidationPattern ( $ data [ 'pattern' ] ) ; } // RAML 1.0 if ( isset ( $ data [ 'validationPattern' ] ) ) { $ namedParameter -> setValidationPattern ( $ data [ 'validationPattern' ] ) ; } if ( isset ( $ data [ 'minLength' ] ) ) { $ namedParameter -> setMinLength ( $ data [ 'minLength' ] ) ; } if ( isset ( $ data [ 'maxLength' ] ) ) { $ namedParameter -> setMaxLength ( $ data [ 'maxLength' ] ) ; } if ( isset ( $ data [ 'minimum' ] ) ) { $ namedParameter -> setMinimum ( $ data [ 'minimum' ] ) ; } if ( isset ( $ data [ 'maximum' ] ) ) { $ namedParameter -> setMaximum ( $ data [ 'maximum' ] ) ; } if ( isset ( $ data [ 'example' ] ) ) { $ namedParameter -> addExample ( $ data [ 'example' ] ) ; } if ( isset ( $ data [ 'examples' ] ) ) { foreach ( $ data [ 'examples' ] as $ example ) { $ namedParameter -> addExample ( $ example ) ; } } if ( isset ( $ data [ 'repeat' ] ) ) { $ namedParameter -> setRepeat ( $ data [ 'repeat' ] ) ; } if ( isset ( $ data [ 'required' ] ) ) { $ namedParameter -> setRequired ( $ data [ 'required' ] ) ; } if ( isset ( $ data [ 'default' ] ) ) { if ( $ namedParameter -> getType ( ) === self :: TYPE_DATE ) { $ namedParameter -> setDefault ( \ DateTimeImmutable :: createFromFormat ( 'D, d M Y H:i:s T' , $ data [ 'default' ] ) ) ; } else { $ namedParameter -> setDefault ( $ data [ 'default' ] ) ; } } if ( isset ( $ data [ 'format' ] ) ) { $ namedParameter -> setFormat ( $ data [ 'format' ] ) ; } return $ namedParameter ; }
Create a Query Parameter from an Array

@param string $key
@param array $data
[
displayName:        ?string
description:        ?string
type:               ?["string","number","integer","date","boolean","file", ...]
enum:               ?array
pattern:            ?string
validationPattern:  ?string
minLength:          ?integer
maxLength:          ?integer
minimum:            ?integer
maximum:            ?integer
example:            ?string
examples:           ?array
repeat:             ?boolean
required:           ?boolean
default:            ?string
format:             ?string
]

@throws \Exception

@return self
Create a Query Parameter from an Array