To create series of related or dependent objects without specifying their concrete classes. Usually the created classes all implement the same interface. The client of the abstract factory does not care about how these objects are created, it just knows how they go together.
You can also find this code on GitHub
Parser.php
.. literalinclude:: Parser.php :language: php :linenos:
CsvParser.php
.. literalinclude:: CsvParser.php :language: php :linenos:
JsonParser.php
.. literalinclude:: JsonParser.php :language: php :linenos:
ParserFactory.php
.. literalinclude:: ParserFactory.php :language: php :linenos:
Tests/AbstractFactoryTest.php
.. literalinclude:: Tests/AbstractFactoryTest.php :language: php :linenos: