original_string: protected function makeNestedDataObject(string $class, $data, $key): DataObjectInterface
      {
          $data = ($data instanceof Arrayable) ? $data->toArray() : $data;
  
          if ( ! is_array($data)) {
  
              throw new UnexpectedValueException(
                  "Cannot instantiate data object '{$class}' with non-array data for key '{$key}'"
                  . (is_scalar($data) || is_object($data) && method_exists($data, '__toString')
                      ?   ' (data: ' . (string) $data . ')'
                      :   null)
              );
          }
  
          /** @var DataObjectInterface $data */
          return new $class($data);
      }
code: protected function makeNestedDataObject(string $class, $data, $key): DataObjectInterface
      {
          $data = ($data instanceof Arrayable) ? $data->toArray() : $data;
  
          if ( ! is_array($data)) {
  
              throw new UnexpectedValueException(
                  "Cannot instantiate data object '{$class}' with non-array data for key '{$key}'"
                  . (is_scalar($data) || is_object($data) && method_exists($data, '__toString')
                      ?   ' (data: ' . (string) $data . ')'
                      :   null)
              );
          }
  
          /** @var DataObjectInterface $data */
          return new $class($data);
      }
code_tokens: protected function makeNestedDataObject ( string $ class , $ data , $ key ) : DataObjectInterface { $ data = ( $ data instanceof Arrayable ) ? $ data -> toArray ( ) : $ data ; if ( ! is_array ( $ data ) ) { throw new UnexpectedValueException ( "Cannot instantiate data object '{$class}' with non-array data for key '{$key}'" . ( is_scalar ( $ data ) || is_object ( $ data ) && method_exists ( $ data , '__toString' ) ? ' (data: ' . ( string ) $ data . ')' : null ) ) ; } /** @var DataObjectInterface $data */ return new $ class ( $ data ) ; }
docstring: Makes a new nested data object for a given class and data.
  
  @param string $class
  @param mixed  $data
  @param string $key
  @return DataObjectInterface
docstring_tokens: Makes a new nested data object for a given class and data .