for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
namespace WsdlToPhp\PackageGenerator\File\Validation;
use WsdlToPhp\PackageGenerator\File\StructEnum;
use WsdlToPhp\PackageGenerator\Model\Struct;
class EnumerationRule extends AbstractRule
{
/**
* @var Struct
*/
protected $model;
* @return string
public function name()
return 'enumeration';
}
* @param string $parameterName
* @param mixed $value
* @param bool $itemType
public function testConditions($parameterName, $value, $itemType = false)
$test = '';
if ($this->getRestrictionModel()) {
$test = sprintf('!%s::%s($%s)', $this->getRestrictionModel()->getPackagedName(true), StructEnum::METHOD_VALUE_IS_VALID, $parameterName);
return $test;
public function exceptionMessageOnTestFailure($parameterName, $value, $itemType = false)
return sprintf('sprintf(\'Invalid value(s) %%s, please use one of: %%s from enumeration class %2$s\', is_array($%1$s) ? implode(\', \', $%1$s) : var_export($%1$s, true), implode(\', \', %2$s::%3$s()))', $parameterName, $this->getRestrictionModel()->getPackagedName(true), StructEnum::METHOD_GET_VALID_VALUES);
* @return Struct|null
protected function getRestrictionModel()
if (!$this->model) {
$this->model = $this->getFile()->getRestrictionFromStructAttribute($this->getAttribute());
return $this->model;