original_string: protected function getUploadedFile($data)
      {
          $file = null;
  
          if ($data !== null && is_array($data) && isset($data[FileType::RADIO_FIELDNAME])) {
              switch ($data[FileType::RADIO_FIELDNAME]) {
                  case FileType::FILE_URL:
                      if (!empty($data[FileType::URL_FIELDNAME])) {
                          $fileurl = $data[FileType::URL_FIELDNAME];
                          $fileparts = explode('/', $fileurl);
  
                          $filename = urldecode(array_pop($fileparts));
                          $parsedFileName = parse_url($filename);
  
                          // We are only interested in the original file path, strip '?...' section
                          $filePath = sprintf('%s/%s', sys_get_temp_dir(), $parsedFileName['path']);
  
                          file_put_contents($filePath, file_get_contents($fileurl));
                          $file = new File($filePath);
                      }
                      break;
                  case FileType::FILE_UPLOAD:
                      if (isset($data[FileType::UPLOAD_FIELDNAME]) && $data[FileType::UPLOAD_FIELDNAME] instanceof UploadedFile) {
                          /** @var UploadedFile $file */
                          $file = $data[FileType::UPLOAD_FIELDNAME];
                      }
                      break;
              }
          }
  
          return $file;
      }
code: protected function getUploadedFile($data)
      {
          $file = null;
  
          if ($data !== null && is_array($data) && isset($data[FileType::RADIO_FIELDNAME])) {
              switch ($data[FileType::RADIO_FIELDNAME]) {
                  case FileType::FILE_URL:
                      if (!empty($data[FileType::URL_FIELDNAME])) {
                          $fileurl = $data[FileType::URL_FIELDNAME];
                          $fileparts = explode('/', $fileurl);
  
                          $filename = urldecode(array_pop($fileparts));
                          $parsedFileName = parse_url($filename);
  
                          // We are only interested in the original file path, strip '?...' section
                          $filePath = sprintf('%s/%s', sys_get_temp_dir(), $parsedFileName['path']);
  
                          file_put_contents($filePath, file_get_contents($fileurl));
                          $file = new File($filePath);
                      }
                      break;
                  case FileType::FILE_UPLOAD:
                      if (isset($data[FileType::UPLOAD_FIELDNAME]) && $data[FileType::UPLOAD_FIELDNAME] instanceof UploadedFile) {
                          /** @var UploadedFile $file */
                          $file = $data[FileType::UPLOAD_FIELDNAME];
                      }
                      break;
              }
          }
  
          return $file;
      }
code_tokens: protected function getUploadedFile ( $ data ) { $ file = null ; if ( $ data !== null && is_array ( $ data ) && isset ( $ data [ FileType :: RADIO_FIELDNAME ] ) ) { switch ( $ data [ FileType :: RADIO_FIELDNAME ] ) { case FileType :: FILE_URL : if ( ! empty ( $ data [ FileType :: URL_FIELDNAME ] ) ) { $ fileurl = $ data [ FileType :: URL_FIELDNAME ] ; $ fileparts = explode ( '/' , $ fileurl ) ; $ filename = urldecode ( array_pop ( $ fileparts ) ) ; $ parsedFileName = parse_url ( $ filename ) ; // We are only interested in the original file path, strip '?...' section $ filePath = sprintf ( '%s/%s' , sys_get_temp_dir ( ) , $ parsedFileName [ 'path' ] ) ; file_put_contents ( $ filePath , file_get_contents ( $ fileurl ) ) ; $ file = new File ( $ filePath ) ; } break ; case FileType :: FILE_UPLOAD : if ( isset ( $ data [ FileType :: UPLOAD_FIELDNAME ] ) && $ data [ FileType :: UPLOAD_FIELDNAME ] instanceof UploadedFile ) { /** @var UploadedFile $file */ $ file = $ data [ FileType :: UPLOAD_FIELDNAME ] ; } break ; } } return $ file ; }
docstring: Get the File object from the form data.
  
  @param array $data
  @return null|File|UploadedFile
docstring_tokens: Get the File object from the form data .