PHP Classes

PHP Polimorphism: Demonstrate several ways to implement polimorphism

Recommend this page to a friend!
  Info   View files Example   View files View files (9)   DownloadInstall with Composer Download .zip   Reputation   Support forum   Blog    
Ratings Unique User Downloads Download Rankings
Not enough user ratingsTotal: 167 This week: 1All time: 8,872 This week: 560Up
Version License PHP version Categories
php-polimorfizm 1.0.0MIT/X Consortium ...5PHP 5, Language
Description 

Author

This package demonstrates several ways to implement polimorphism in PHP.

It provides different classes and examples that implement polimorphism in different ways as a means to create objects in such a way that applications can call different the same way but each object has their own behavior.

Currently it provides classes that implement polimorphism using abstract classes, interfaces, sub-class extensions and traits.

Innovation Award
PHP Programming Innovation award nominee
June 2019
Number 4
Polimorphism is a means for providing access to different objects in the same way but the objects have different behavior.

This package demonstrates how to implement polimorphism in PHP using either abstract classes, interfaces, sub-class extensions and traits.

Manuel Lemos
Picture of adam berger
  Performance   Level  
Name: adam berger <contact>
Classes: 23 packages by
Country: Poland Poland
Age: ???
All time rank: 74621 in Poland Poland
Week rank: 52 Up3 in Poland Poland Up
Innovation award
Innovation award
Nominee: 8x

Winner: 2x

Example

<?php

require_once(dirname(__FILE__) ."/Class-Abstract-Polimorf.php");
 
####### Book ########
 
 
$tytulBook = "Book Manager Wydobycia";
 
$autorBook = "Adam Ber Book";
 
$cenaBook = "10 z?";
 
$isbn = "12-234-435-1";

 
  
$book1 = new Book();
 
  
$book1->setTytul($tytulBook);
 
// Tytul
 
echo $book1->getTytul()."<br>";
 
  
$book1->setAutor($autorBook);
 
// Autor
 
echo $book1->getAutor()."<br>";
 
 
$book1->setCena($cenaBook);
  
// Cena
 
echo $book1->getCena()."<br><br>";

   
$book1->setIsbn($isbn);
  
// Isbn
 
echo $book1->getIsbn()."<br><br>";
 
 
####### Komiks ########
 
 
$tytulKomiks = "Komiks Manager Wydobycia";
 
$autorKomiks = "Adam Ber Komiks";
 
$cenaKomiks = "5 z?";
 
$seriesNumber = "10/99";
 
  
$komiks1 = new Komiks();
 
  
$komiks1->setTytul($tytulKomiks);
 
// Tytul
 
echo $komiks1->getTytul()."<br>";
 
 
$komiks1->setAutor($autorKomiks);
 
// Autor
 
echo $komiks1->getAutor()."<br>";
 
 
$komiks1->setCena($cenaKomiks);
  
// Cena
 
echo $komiks1->getCena()."<br><br>";

 
$komiks1->setSeriesNumber($seriesNumber);
  
// Seria wydania numeru Series Number
 
echo $komiks1->getSeriesNumber()."<br><br>";




Details

PHP-polimorfizm

Ucz?c si? na testy programowania oop w PHP natrafi?em na ciekawy temat jakim jest polimorfizm.
Z racji tego, ?e ma?o by?o materia?ów na ten temat w j?zyku Polskim postanowi?em troszk? u?atwi?
nauk? przysz?ym programistom, szukaj?cym jaki? materia?ów na temat polimorfizmu, dziel?c go na kategorie. 
Nie spotka?em si? z takim podzia?em,  wi?c mam nadziej?, ?e dobrze zrobi?em dziel?c go na cztery kategorie. 
Uwa?am podzia? na kategorie za ?atwiej przyswajalne, zrozumia?e i przejrzyste do dalszej nauki. 

  1. Polimorfizm Interfejsowy
  2. Polimorfizm Abstrakcyjny
  3. Polimorfizm Traits
  4. Polimorfizm Dziedziczony

PHP-Polymorphism EN

While learning about oop programming tests in PHP, I came across an interesting topic, which is polymorphism. Due to the fact that there were few materials on this subject in Polish, I decided to make it a little easier learning for future programmers looking for some materials about polymorphism, dividing it into categories. I have not met with such a division, so I hope I did well by dividing it into four categories. I consider the division into categories to be more easily absorbed, understandable and transparent for further learning.

  1. Interface Polymorphism
  2. Polymorphism Abstract
  3. Polymorphism Traits
  4. Polymorphism Inherited

  Files folder image Files  
File Role Description
Plain text file Class-Abstract-Polimorf.php Class Class source
Plain text file Class-Extends-Polimorf.php Class Class source
Plain text file Class-Interface-Polimorf.php Class Class source
Plain text file Class-Traits-Polimorf.php Class Class source
Accessible without login Plain text file index-Abstract.php Example Example script
Accessible without login Plain text file index-Extends.php Example Example script
Accessible without login Plain text file index-Interface.php Example Example script
Accessible without login Plain text file index-Traits.php Example Example script
Accessible without login Plain text file README.md Doc. Documentation

 Version Control Unique User Downloads Download Rankings  
 100%
Total:167
This week:1
All time:8,872
This week:560Up