<commit_before>Simple Factory
==============

Purpose
-------

SimpleFactory is a simple factory pattern.

It differs from the static factory because it is not static.
Therefore, you can have multiple factories, differently parametrized, you can subclass it and you can mock it.
It always should be preferred over a static factory!

UML Diagram
-----------

.. image:: uml/uml.png
   :alt: Alt SimpleFactory UML Diagram
   :align: center

Code
----

You can also find these code on `GitHub`_

SimpleFactory.php

.. literalinclude:: SimpleFactory.php
   :language: php
   :linenos:

VehicleInterface.php

.. literalinclude:: VehicleInterface.php
   :language: php
   :linenos:

Bicycle.php

.. literalinclude:: Bicycle.php
   :language: php
   :linenos:

Usage
-----

.. code::  php

   $factory = new SimpleFactory();
   $bicycle = $factory->createVehicle('bicycle');
   $bicycle->driveTo('Paris');

Test
----

Tests/SimpleFactoryTest.php

.. literalinclude:: Tests/SimpleFactoryTest.php
   :language: php
   :linenos:

.. _`GitHub`: https://github.com/domnikl/DesignPatternsPHP/tree/master/Creational/SimpleFactory<commit_msg>fsdfsdwerewrweeix creation<commit_after>Simple Factory
==============

Purpose
-------

SimpleFactory is a simple factory pattern.

It differs from the static factory because it is not static.
Therefore, you can have multiple factories, differently parametrized, you can subclass it and you can mock it.
It always should be preferred over a static factory!

UML Diagram
-----------

.. image:: uml/uml.png
   :alt: Alt SimpleFactory UML Diagram
   :align: center

Code
----

You can also find these code on `GitHub`_

SimpleFactory.php

.. literalinclude:: SimpleFactory.php
   :language: php
   :linenos:

VehicleInterface.php

.. literalinclude:: VehicleInterface.php
   :language: php
   :linenos:

Bicycle.php

.. literalinclude:: Bicycle.php
   :language: php
   :linenos:

Usage
-----

.. code::  php

   $factory = new SimpleFactory();
   $bicycle = $factory->createBicycle();
   $bicycle->driveTo('Paris');

Test
----

Tests/SimpleFactoryTest.php

.. literalinclude:: Tests/SimpleFactoryTest.php
   :language: php
   :linenos:

.. _`GitHub`: https://github.com/domnikl/DesignPatternsPHP/tree/master/Creational/SimpleFactory
{'fraction_non_alphanumeric': 0.1328609388839681, 'fraction_numerical': 0.0, 'mean_word_length': 3.5544354838709675, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 7, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4493886', 'n_tokens_mistral': 739, 'n_tokens_neox': 694, 'n_words': 204}