本文整理汇总了PHP中Parameter类的典型用法代码示例。如果您正苦于以下问题:PHP Parameter类的具体用法?PHP Parameter怎么用?PHP Parameter使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Parameter类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: generate
/**
* Generates the actual interfaces
*/
public function generate()
{
$interfacesData = json_decode($this->json, true);
foreach ($interfacesData as $interface) {
$filename = $interface['name'] . '.java';
$interfaceObject = new JAVAInterfaceObject();
$interfaceObject->setName($interface['name']);
foreach ($interface['methods'] as $method) {
$methodObject = new JAVAMethod();
$methodObject->setName($method['name']);
$methodObject->setReturnValue($method['returnType']);
$methodObject->setScope($method['scope']);
$methodObject->setComment($method['comment']);
foreach ($method['parameters'] as $parameter) {
$parameterObject = new Parameter();
$parameterObject->setName($parameter['name']);
$parameterObject->setType($parameter['type']);
$methodObject->addParameter($parameterObject);
}
foreach ($method['annotations'] as $annotation) {
$annotationObject = new Annotation();
$annotationObject->setName($annotation['name']);
$annotationObject->setValue($annotation['value']);
$annotationObject->setInterpreter('@');
$methodObject->addAnnotation($annotationObject);
}
$interfaceObject->addMethod($methodObject);
}
file_put_contents($this->folder . DIRECTORY_SEPARATOR . $filename, $interfaceObject->toString());
}
}
示例2: addParameter
/**
* @param \hergot\databroker\DataAdapter\Parameter $parameter
* @throws \InvalidArgumentException
*/
public function addParameter(Parameter $parameter)
{
if (isset($this->parameters[$parameter->getName()])) {
throw new \InvalidArgumentException('Parameter with name "' . $parameter->getName() . '" already defined');
}
$this->parameters[$parameter->getName()] = $parameter;
}
示例3: doManipulation
/**
* @see ItemParameterManipulation::doManipulation
*
* @since 0.7.5
*/
public function doManipulation(&$value, Parameter $parameter, array &$parameters)
{
global $egMapsDefaultGeoService;
static $validatedDefault = false;
if (!MapsGeocoders::canGeocode()) {
throw new MWException('There are no geocoders registered, so no geocoding can happen.');
}
// Get rid of any aliases.
$value = $this->getMainIndentifier($value);
// Override the defaulting.
if ($parameter->wasSetToDefault() && is_string($this->mappingServiceParam) && array_key_exists($this->mappingServiceParam, $parameters)) {
$value = self::resolveOverrides($value, $parameters[$this->mappingServiceParam]->getValue());
}
if ($value === '' || !array_key_exists($value, MapsGeocoders::$registeredGeocoders)) {
if (!$validatedDefault) {
if (!array_key_exists($egMapsDefaultGeoService, MapsGeocoders::$registeredGeocoders)) {
$geoServices = array_keys(MapsGeocoders::$registeredGeocoders);
$egMapsDefaultGeoService = array_shift($geoServices);
if (is_null($egMapsDefaultGeoService)) {
throw new MWException('Tried to geocode while there are no geocoders available at ' . __METHOD__);
}
}
}
if (array_key_exists($egMapsDefaultGeoService, MapsGeocoders::$registeredGeocoders)) {
$value = $egMapsDefaultGeoService;
} else {
throw new MWException('Attempt to use the default geocoder while it does not exist.');
}
}
}
示例4: doManipulation
/**
* @see ItemParameterManipulation::doManipulation
*
* @since 0.4
*/
public function doManipulation(&$value, Parameter $parameter, array &$parameters)
{
// When the value defaulted to a boolean, there is no need for this manipulation.
if (!is_bool($value) || !$parameter->wasSetToDefault()) {
$value = in_array($value, array('yes', 'on'));
}
}
示例5: addParameter
/**
*
* @param Parameter $parameter
* @return void
* @throws \InvalidArgumentException
*/
private function addParameter(Parameter $parameter)
{
$name = $parameter->getDefinition()->getName();
if (array_key_exists($name, $this->parameters)) {
throw new \InvalidArgumentException("Parameter '{$name}' provided multiple times.");
}
$this->parameters[$name] = $parameter;
}
示例6: addParameter
public function addParameter(Parameter $parameter, $in = true)
{
if ($in) {
$this->inputParameters[$parameter->getName()] = $parameter;
} else {
$this->outputParameters[$parameter->getName()] = $parameter;
}
}
示例7: testWithersReturnNewModifiedInstance
public function testWithersReturnNewModifiedInstance()
{
$parameter = new Parameter('foo', 'bar');
$newParam = $parameter->withValue('rab');
$this->assertNotSame($newParam, $parameter);
$this->assertEquals('bar', $parameter->getValue());
$this->assertEquals('rab', $newParam->getValue());
}
示例8: doManipulation
/**
* @see ItemParameterManipulation::doManipulation
*
* @since 0.7
*/
public function doManipulation(&$value, Parameter $parameter, array &$parameters)
{
// If there are multiple points and the value was not provided or incorrect (=defaulted),
// set it to false, so the mapping service can figure out the optimal value.
if ($parameter->wasSetToDefault() && count($parameters['coordinates']->getValue()) > 1) {
$value = false;
}
}
示例9: getItemErrorMessage
/**
* @see ItemParameterCriterion::getItemErrorMessage
*/
protected function getItemErrorMessage(Parameter $parameter)
{
global $wgLang;
if ($this->lowerBound == $this->upperBound) {
return wfMsgExt('validator-error-invalid-length', 'parsemag', $parameter->getOriginalName(), $wgLang->formatNum($this->lowerBound));
} else {
return wfMsgExt('validator-error-invalid-length-range', 'parsemag', $parameter->getOriginalName(), $wgLang->formatNum($this->lowerBound), $wgLang->formatNum($this->upperBound));
}
}
示例10: manipulate
/**
* Validate a parameter against the criterion.
*
* @param Parameter $parameter
* @param array $parameters
*
* @since 0.4
*/
public function manipulate(Parameter &$parameter, array &$parameters)
{
if (is_array($parameter->getValue())) {
$value =& $parameter->getValue();
foreach ($value as &$item) {
$this->doManipulation($item, $parameter, $parameters);
}
} else {
$this->doManipulation($parameter->getValue(), $parameter, $parameters);
}
}
示例11: addParameter
/**
* Adds a parameter to the widget
*
* @param Parameter $new_parameter
* @return void
*/
public function addParameter($new_parameter)
{
if (!$new_parameter instanceof Parameter) {
throw new \MWException('Method addParameter() of widget ' . static::GetName() . ' requires an argument of type "Parameter".');
}
$new_parameter_name = $new_parameter->getName();
if (array_key_exists($new_parameter_name, $this->parameters)) {
throw new \MWException('Cannot add parameter "' . $new_parameter_name . '". Each parameter needs a disctinct name.');
}
$this->parameters[$new_parameter_name] = $new_parameter;
}
示例12: defineParameter
public function defineParameter($key, $type, $label, $default = null)
{
if (isset($this->parameter[$key])) {
throw new \InvalidArgumentException('Parameter already define in bag: ' . $key);
}
$parameter = new Parameter();
$parameter->setKey($key);
$parameter->setType($type);
$parameter->setLabel($label);
$parameter->setDefault($default);
$this->parameter[$key] = $parameter;
}
示例13: testRequirementParameterSuccess
public function testRequirementParameterSuccess()
{
$parameter = new Parameter();
$parameter->name = "NEEDLE_LENGTH";
$parameter->type = "float";
$parameter->widget = null;
$parameter->value = null;
$parameter->priority = 2;
$parameter->paramable_id = '-1';
$parameter->paramable_type = '';
$this->assertTrue($parameter->save());
}
示例14: manipulate
/**
* @see ParameterManipulation::manipulate
*
* @since 1.0.1
*/
public function manipulate(Parameter &$parameter, array &$parameters)
{
if (!in_array($parameters['type']->getValue(), $parameter->getValue())) {
if ($parameters['type']->wasSetToDefault()) {
if (count($parameter->getValue()) > 0) {
$types = $parameter->getValue();
$parameters['type']->setValue($types[0]);
}
} else {
array_unshift($parameter->getValue(), $parameters['type']->getValue());
}
}
}
示例15: setParameter
private function setParameter(Parameter $param)
{
$set_param_head = 'SET_PARAM ' . $param->getKey();
try {
if ($param->isRawValue()) {
$raw_value = self::BEGIN_RAW . "\n" . base64_encode($param->getValue()) . "\n" . self::END_RAW;
return $this->socket_client->request($set_param_head . ' ' . self::RAW_VALUE_ANNOUNCMENT . "\n" . $raw_value);
} else {
return $this->socket_client->request($set_param_head . ' ' . $param->getValue());
}
} catch (\Exception $e) {
throw $e;
}
}