/** * A generic method that will populate a JSON structure with a value according to a schema. It * supports multiple types and will delegate accordingly. * * @param Parameter $param The schema that defines how the JSON field is being populated * @param mixed $userValue The user value that is populating a JSON field * @param array $json The existing JSON structure that will be populated * * @return array */ public function stockJson(Parameter $param, $userValue, array $json) : array { if ($param->isArray()) { $userValue = $this->stockArrayJson($param, $userValue); } elseif ($param->isObject()) { $userValue = $this->stockObjectJson($param, $this->serializeObjectValue($userValue)); } // Populate the final value return $this->stockValue($param, $userValue, $json); }
/** * A generic method that will populate a JSON structure with a value according to a schema. It * supports multiple types and will delegate accordingly. * * @param mixed $userValue The user value that is populating a JSON field * @param Parameter $param The schema that defines how the JSON field is being populated * @param array $json The existing JSON structure that will be populated * * @return array */ private function stockJson($userValue, Parameter $param, $json) { if ($param->isArray()) { $userValue = $this->stockArrayJson($userValue, $param); } elseif ($param->isObject()) { $userValue = $this->stockObjectJson($userValue, $param); } // Populate the final value return $this->stockValue($userValue, $param, $json); }