public function __construct(array $values)
{
// Process the parameters as a list AND as a parameter array (we don't know on what the annotation is)
// @Inject(name="foo")
if (isset($values['name']) && is_string($values['name'])) {
$this->name = $values['name'];
return;
}
// @Inject
if (!isset($values['value'])) {
return;
}
$values = $values['value'];
// @Inject("foo")
if (is_string($values)) {
$this->name = $values;
}
// @Inject({...}) on a method
if (is_array($values)) {
foreach ($values as $key => $value) {
if (!is_string($value)) {
throw new AnnotationException(sprintf('@Inject({"param" = "value"}) expects "value" to be a string, %s given.', json_encode($value)));
}
$this->parameters[$key] = $value;
}
}
}