The Factory Method pattern suggests that you replace direct object construction calls (using the new operator) with calls to a special factory method. Don’t worry: the objects are still created via the new operator, but it’s being called from within the factory method. Objects returned by a factory method are often referred to as products.
Use the Factory Method when you don’t know beforehand the exact types and dependencies of the objects your code should work with.
The Factory Method separates product construction code from the code that actually uses the product. Therefore it’s easier to extend the product construction code independently from the rest of the code.

Example in PHP:
<?php

interface IDeliveryType
{
public function executeDelivery();
}

class TruckDelivery implements IDeliveryType
{
public function executeDelivery()
{
echo "Making delivery by truck</br>";
}
}

class AirDelivery implements IDeliveryType
{
public function executeDelivery()
{
echo "Making delivery by plane</br>";
}
}

abstract class DeliveryCreator
{
abstract public function createDelivery(): IDeliveryType;
}

class TruckDeliveryCreator extends DeliveryCreator
{
public function createDelivery(): IDeliveryType
{
return new TruckDelivery();
}
}

class AirDeliveryCreator extends DeliveryCreator
{
public function createDelivery(): IDeliveryType
{
return new AirDelivery();
}
}

// Client code

$delivery = new AirDeliveryCreator();
$delivery->createDelivery()->executeDelivery();
$delivery2 = new TruckDeliveryCreator();
$delivery2->createDelivery()->executeDelivery();

Result:
Making delivery by plane
Making delivery by truck
Abridged version:

<?php

abstract class Delivery
{
public static function create($type): Delivery
{
return new $type;
}
abstract public function executeDelivery();
}

class TruckDelivery extends Delivery
{
public function executeDelivery()
{
echo "Making delivery by truck</br>";
}
}

class AirDelivery extends Delivery
{
public function executeDelivery()
{
echo "Making delivery by plane</br>";
}
}

$delivery1 = Delivery::create("TruckDelivery");
$delivery2 = Delivery::create("AirDelivery");

$delivery1->executeDelivery();
$delivery2->executeDelivery();


Result:

Making delivery by plane
Making delivery by truck
0