How to create a media entity from image url in Drupal 10

<?php

use Drupal\media\Entity\Media;
use Drupal\Core\File\FileSystemInterface;

$image_data = file_get_contents('https://learndrupalway.com/themes/claro/images/learndrupal.png');
$file_repository = \Drupal::service('file.repository');
$image = $file_repository->writeData($image_data, "public://learndrupal.png", FileSystemInterface::EXISTS_REPLACE);

$media = Media::create([
 'name' => 'Learn Drupal',
 'bundle' => 'image',
 'uid' => 1,
 'langcode' => 'en',
 'status' => 0,
 'field_media_image' => [
   'target_id' => $image->id(),
   'alt' => t('Learn Drupal.png'),
   'title' => t('Learn Drupal'),
 ],
]);
$media->save();

Category