PHP Polymorphism Example: Show several ways of implementing of polymorphism

Recommend this page to a friend!

  Author Author  
Picture of Manolo Salsas
Name: Manolo Salsas <contact>
Classes: 7 packages by
Country: Spain Spain
Innovation award
Innovation award
Nominee: 5x

Winner: 1x


  Detailed description   Download Download .zip .tar.gz  
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

Details

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


  Classes of Manolo Salsas  >  PHP Polymorphism Example  >  Download Download .zip .tar.gz  >  Support forum Support forum  >  Blog Blog  >  RSS 1.0 feed RSS 2.0 feed Latest changes  
Name: PHP Polymorphism Example
Base name: polymorphism
Description: Show several ways of implementing of polymorphism
Version: -
PHP version: 5
License: The PHP License
 
  Groups   Applications   Files Files  

  Groups  
Group folder image PHP 5 Classes using PHP 5 specific features View top rated classes
Group folder image Language Constructs to assist in the language control View top rated classes
Group folder image Design Patterns Implementations of well known design patterns View top rated classes


  Applications that use this package  
No pages of applications that use this class were specified.

Add link image If you know an application of this package, send a message to the author to add a link here.

  Files folder image Files  
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

  Files folder image Files  /  app  
File Role Description
Files folder imageconfig (9 files)
Files folder imageResources (1 directory)
  Accessible without login Plain text file .htaccess Data Auxiliary data
  Plain text file AppCache.php Class Class source
  Plain text file AppKernel.php Class Class source

  Files folder image Files  /  app  /  config  
File Role Description
  Accessible without login Plain text file config.yml Data Auxiliary data
  Accessible without login Plain text file config_dev.yml Data Auxiliary data
  Accessible without login Plain text file config_prod.yml Data Auxiliary data
  Accessible without login Plain text file config_test.yml Data Auxiliary data
  Accessible without login Plain text file parameters.yml.dist Data Auxiliary data
  Accessible without login Plain text file routing.yml Data Auxiliary data
  Accessible without login Plain text file routing_dev.yml Data Auxiliary data
  Accessible without login Plain text file security.yml Data Auxiliary data
  Accessible without login Plain text file services.yml Data Auxiliary data

  Files folder image Files  /  app  /  Resources  
File Role Description
Files folder imageviews (1 file, 1 directory)

  Files folder image Files  /  app  /  Resources  /  views  
File Role Description
Files folder imagedefault (1 file)
  Accessible without login Plain text file base.html.twig Data Auxiliary data

  Files folder image Files  /  app  /  Resources  /  views  /  default  
File Role Description
  Accessible without login Plain text file index.html.twig Data Auxiliary data

  Files folder image Files  /  bin  
File Role Description
  Accessible without login Plain text file console Example Example script
  Accessible without login Plain text file symfony_requirements Example Example script

  Files folder image Files  /  docs  
File Role Description
  Accessible without login Plain text file polimorfismo.md Data Auxiliary data

  Files folder image Files  /  src  
File Role Description
Files folder imageAppBundle (1 file, 3 directories)
  Accessible without login Plain text file .htaccess Data Auxiliary data

  Files folder image Files  /  src  /  AppBundle  
File Role Description
Files folder imageController (1 file)
Files folder imageModel (4 directories)
Files folder imageService (4 directories)
  Plain text file AppBundle.php Class Class source

  Files folder image Files  /  src  /  AppBundle  /  Controller  
File Role Description
  Plain text file DefaultController.php Class Class source

  Files folder image Files  /  src  /  AppBundle  /  Model  
File Role Description
Files folder imageAbstractInheritance (5 files)
Files folder imageBasic (2 files)
Files folder imageInheritance (3 files)
Files folder imageInterfaceImplementation (5 files)

  Files folder image Files  /  src  /  AppBundle  /  Model  /  AbstractInheritance  
File Role Description
  Plain text file Animal.php Class Class source
  Plain text file Cat.php Class Class source
  Plain text file Dog.php Class Class source
  Plain text file Lion.php Class Class source
  Plain text file Pet.php Class Class source

  Files folder image Files  /  src  /  AppBundle  /  Model  /  Basic  
File Role Description
  Plain text file Cat.php Class Class source
  Plain text file Lion.php Class Class source

  Files folder image Files  /  src  /  AppBundle  /  Model  /  Inheritance  
File Role Description
  Plain text file Animal.php Class Class source
  Plain text file Cat.php Class Class source
  Plain text file Lion.php Class Class source

  Files folder image Files  /  src  /  AppBundle  /  Model  /  InterfaceImplementation  
File Role Description
  Plain text file Animal.php Class Class source
  Plain text file Cat.php Class Class source
  Plain text file Dog.php Class Class source
  Plain text file Lion.php Class Class source
  Plain text file Pet.php Class Class source

  Files folder image Files  /  src  /  AppBundle  /  Service  
File Role Description
Files folder imageAbstractInheritance (1 file)
Files folder imageBasic (1 file)
Files folder imageInheritance (1 file)
Files folder imageInterfaceImplementation (1 file)

  Files folder image Files  /  src  /  AppBundle  /  Service  /  AbstractInheritance  
File Role Description
  Plain text file AnimalService.php Class Class source

  Files folder image Files  /  src  /  AppBundle  /  Service  /  Basic  
File Role Description
  Plain text file AnimalService.php Class Class source

  Files folder image Files  /  src  /  AppBundle  /  Service  /  Inheritance  
File Role Description
  Plain text file AnimalService.php Class Class source

  Files folder image Files  /  src  /  AppBundle  /  Service  /  InterfaceImplementation  
File Role Description
  Plain text file AnimalService.php Class Class source

  Files folder image Files  /  tests  
File Role Description
Files folder imageAppBundle (2 directories)

  Files folder image Files  /  tests  /  AppBundle  
File Role Description
Files folder imageModel (2 directories)
Files folder imageService (4 directories)

  Files folder image Files  /  tests  /  AppBundle  /  Model  
File Role Description
Files folder imageBasic (2 files)
Files folder imageInheritance (3 files)

  Files folder image Files  /  tests  /  AppBundle  /  Model  /  Basic  
File Role Description
  Plain text file CatTest.php Class Class source
  Plain text file LionTest.php Class Class source

  Files folder image Files  /  tests  /  AppBundle  /  Model  /  Inheritance  
File Role Description
  Plain text file AnimalTest.php Class Class source
  Plain text file CatTest.php Class Class source
  Plain text file LionTest.php Class Class source

  Files folder image Files  /  tests  /  AppBundle  /  Service  
File Role Description
Files folder imageAbstractInheritance (1 file)
Files folder imageBasic (1 file)
Files folder imageInheritance (1 file)
Files folder imageInterfaceImplementation (1 file)

  Files folder image Files  /  tests  /  AppBundle  /  Service  /  AbstractInheritance  
File Role Description
  Plain text file AnimalServiceTest.php Class Class source

  Files folder image Files  /  tests  /  AppBundle  /  Service  /  Basic  
File Role Description
  Plain text file AnimalServiceTest.php Class Class source

  Files folder image Files  /  tests  /  AppBundle  /  Service  /  Inheritance  
File Role Description
  Plain text file AnimalServiceTest.php Class Class source

  Files folder image Files  /  tests  /  AppBundle  /  Service  /  InterfaceImplementation  
File Role Description
  Plain text file AnimalServiceTest.php Class Class source

  Files folder image Files  /  var  
File Role Description
  Plain text file SymfonyRequirements.php Class Class source

  Files folder image Files  /  web  
File Role Description
  Accessible without login Plain text file .htaccess Data Auxiliary data
  Accessible without login Plain text file app.php Example Example script
  Accessible without login Image file apple-touch-icon.png Icon Icon image
  Accessible without login Plain text file app_dev.php Example Example script
  Accessible without login Plain text file config.php Example Example script
  Accessible without login Image file favicon.ico Data Auxiliary data
  Accessible without login Plain text file robots.txt Doc. Documentation

Download Download all files: polymorphism.tar.gz polymorphism.zip
NOTICE: if you are using a download manager program like 'GetRight', please Login before trying to download this archive.

For more information send a message to info at phpclasses dot org.