private function resolveValue(array $param, Resource $resource, Command $command = null, ResultInterface $result = null) { switch ($param['source']) { // Source is pulled from the resource's identifier. case 'identifier': $id = $resource->getIdentity(); return isset($id[$param['name']]) ? $id[$param['name']] : null; // Source is pulled from the resource's data. // Source is pulled from the resource's data. case 'data': return jp\search($param['path'], $resource); // Source is pulled from the command parameters. // Source is pulled from the command parameters. case 'requestParameter': return $command[$param['path']]; // Source is pulled from the result. // Source is pulled from the result. case 'response': return $result ? $result->search($param['path']) : null; // Source is a literal value from the resource model. // Source is a literal value from the resource model. case 'string': case 'integer': case 'boolean': return $param['value']; // Invalid source type. // Invalid source type. default: throw new \InvalidArgumentException('The value "' . $param['source'] . '" is an invalid for source.'); } }