Question: I have abstract class-factory `Factory` with factory-method `getProduct()` and his child classes.

I have abstract class-product `Product` and his child classes.

Classes-factories created objects of classes-products.

```
abstract class Factory {
    abstract function getProduct();
}
class FirstFactory extends Factory {
    public function getProduct() {
        return new FirstProduct();
    }
}

abstract class Product {
};
class FirstProduct extends Product {
}

```

In result I can use this client code:

```
$factory = new FirstFactory();
$firstProduct = $factory->getProduct();
$factory = new SecondFactory();
$secondProduct = $factory->getProduct();

```

Question: what for this pattern is necessary? Because in client code I just can use direct classes:

```
$firstProduct = new FirstProduct();
$secondProduct = new SecondProduct();

```

Answer: 
If you know at compile time that `firstProduct` is always of type `FirstProduct` and `secondProduct` is always of type `SecondProduct` then there is no need for an factory method.

A factory method is only useful if you want to create a product that might be `FirstProduct` or might be `SecondProduct` depending on the runtime type of a factory. Perhaps, for example, the type of the factory is decided by user input.
a Factory can be injected instead of the actual class. Suppose you have a class that can be instantiated only at runtime based on some specific conditions, in this case you cannot do new Foo(...args) . 
One option is to inject FooFactory instead and have it create the Foo instance for you.