PHP Classes

PHP Polymorphism Example: Show several ways of implementing of polymorphism

Recommend this page to a friend!
  Info   Documentation   View files Files   Install with Composer Install with Composer   Download Download   Reputation   Support forum   Blog    
Ratings Unique User Downloads Download Rankings
Not yet rated by the usersTotal: 69 All time: 10,313 This week: 560Up
Version License PHP version Categories
polymorphism 1.0.0The PHP License5PHP 5, Language, Design Patterns
Description 

Author

This package can show several ways of implementing of polymorphism in PHP.

It provides examples of PHP code that implement means to create objects that provide the same way to execute the same operations even though the objects are of different classes. Currently it provides examples to implement polimorphism using:

- Without class inheritance
- With class inheritance
- With abstract classes and inheritance
- With interfaces

Picture of Manolo Salsas
  Performance   Level  
Innovation award
Innovation award
Nominee: 6x

Winner: 1x

 

Documentation

Polymorphism

This is a project to explain the polymorphism concept diving into:

  • No inheritance
  • Inheritance
  • Abstraction and inheritance
  • Interface implementation

You can find examples guiding you through all of the steps bellow

  • [Service\Basic][1] uses models from [Model\Basic][2]
  • [Service\Inheritance][3] uses models from [Model\Inheritance][4]
  • [Service\AbstractInheritance][5] uses models from [Model\AbstractInheritance][6]
  • [Service\InterfaceImplementation][7] uses models from [Model\InterfaceImplementation][8]

Extended explanation in spanish can be found [here][9]

[1]: https://github.com/motorflash/polymorphism/tree/master/src/AppBundle/Service/Basic [2]: https://github.com/motorflash/polymorphism/tree/master/src/AppBundle/Model/Basic [3]: https://github.com/motorflash/polymorphism/tree/master/src/AppBundle/Service/Inheritance [4]: https://github.com/motorflash/polymorphism/tree/master/src/AppBundle/Model/Inheritance [5]: https://github.com/motorflash/polymorphism/tree/master/src/AppBundle/Service/AbstractInheritance [6]: https://github.com/motorflash/polymorphism/tree/master/src/AppBundle/Model/AbstractInheritance [7]: https://github.com/motorflash/polymorphism/tree/master/src/AppBundle/Service/InterfaceImplementation [8]: https://github.com/motorflash/polymorphism/tree/master/src/AppBundle/Model/InterfaceImplementation [9]: https://github.com/motorflash/polymorphism/tree/master/docs/polimorfismo.md

Testing

./vendor/bin/phpunit


  Files folder image Files (61)  
File Role Description
Files folder imageapp (3 files, 2 directories)
Files folder imagebin (2 files)
Files folder imagedocs (1 file)
Files folder imagesrc (1 file, 1 directory)
Files folder imagetests (1 directory)
Files folder imagevar (1 file)
Files folder imageweb (7 files)
Accessible without login Plain text file composer.json Data Auxiliary data
Accessible without login Plain text file composer.lock Data Auxiliary data
Accessible without login Plain text file LICENSE Lic. License text
Accessible without login Plain text file phpunit.xml.dist Data Auxiliary data
Accessible without login Plain text file README.md Doc. Documentation

The PHP Classes site has supported package installation using the Composer tool since 2013, as you may verify by reading this instructions page.
Install with Composer Install with Composer
 Version Control Unique User Downloads Download Rankings  
 100%
Total:69
This week:0
All time:10,313
This week:560Up