PHP Classes

Design patterns: Implements several well known design patterns

Recommend this page to a friend!
  Info   View files Example   View files View files (43)   DownloadInstall with Composer Download .zip   Reputation   Support forum   Blog    
Ratings Unique User Downloads Download Rankings
StarStarStarStar 76%Total: 334 This week: 1All time: 7,113 This week: 560Up
Version License PHP version Categories
dp2 1.0.1GNU General Publi...5PHP 5, Design Patterns
Description 

Author

This package implements several well known design patterns.

It provides several classes that demonstrate how to use certain design patterns.

Currently it provides classes that implement the design patterns: facade, strategy, command, and proxy.

Picture of Nemeth Zoltan
  Performance   Level  
Name: Nemeth Zoltan is available for providing paid consulting. Contact Nemeth Zoltan .
Classes: 9 packages by
Country: Hungary Hungary
Age: 46
All time rank: 157113 in Hungary Hungary
Week rank: 411 Up4 in Hungary Hungary Up
Innovation award
Innovation award
Nominee: 2x

Winner: 1x

Example

<?php
/**
 * Created by PhpStorm.
 * User: nemeth.zoltan
 * Date: 2016. 05. 13.
 * Time: 15:17
 */
include __DIR__ . '/vendor/autoload.php';

//
// Részvény
//
$stock = new \DP\Command\Model\Stock();

//
// Brókerek
//
$brokers = array();
$brokers[] = new \DP\Command\Model\Broker('Broker Béla');
$brokers[] = new \DP\Command\Model\Broker('Broker Elemér');

foreach (
$brokers as $broker) {
    for (
$i = 0; $i <= 10; $i++) {
        if (
mt_rand(0, 1)) {
           
$broker->placeOrder(new \DP\Command\Command\Buy($stock));
        } else {
           
$broker->placeOrder(new \DP\Command\Command\Sell($stock));
        }
    }
    echo
'<br>' . $broker;
    echo
'<br><strong>Place orders</strong><br>';
   
$broker->closeDay();
}



Details

Design patterns II.

Overview

This repo is an example for my second Design Pattern workshop on the AionHill - Magento Development company.

Design pattern examples

- Facade pattern - Strategy pattern - Command pattern - Proxy pattern


  Files folder image Files  
File Role Description
Files folder imagetemplates (1 file)
Files folder imagevendor (1 file, 2 directories)
Accessible without login Plain text file command.php Example Example script
Accessible without login Plain text file composer.json Data Auxiliary data
Accessible without login Plain text file facade.php Example Example script
Accessible without login Plain text file index.php Aux. Auxiliary script
Accessible without login Plain text file LICENSE Lic. License text
Accessible without login Plain text file proxy.php Example Example script
Accessible without login Plain text file README.md Doc. Documentation
Accessible without login Plain text file strategy.php Example Example script

  Files folder image Files  /  templates  
File Role Description
  Accessible without login Plain text file template1.php Aux. Auxiliary script

  Files folder image Files  /  vendor  
File Role Description
Files folder imagecomposer (8 files)
Files folder imageDP (5 directories)
  Accessible without login Plain text file autoload.php Aux. Auxiliary script

  Files folder image Files  /  vendor  /  composer  
File Role Description
  Accessible without login Plain text file autoload_classmap.php Aux. Auxiliary script
  Accessible without login Plain text file autoload_namespaces.php Aux. Auxiliary script
  Accessible without login Plain text file autoload_psr4.php Aux. Auxiliary script
  Plain text file autoload_real.php Class Class source
  Plain text file autoload_static.php Class Class source
  Plain text file ClassLoader.php Class Class source
  Accessible without login Plain text file installed.json Data Auxiliary data
  Accessible without login Plain text file LICENSE Lic. License text

  Files folder image Files  /  vendor  /  DP  
File Role Description
Files folder imageCommand (2 directories)
Files folder imageFacade (1 file, 2 directories)
Files folder imageGeneral (1 file)
Files folder imageProxy (1 directory)
Files folder imageStrategy (3 directories)

  Files folder image Files  /  vendor  /  DP  /  Command  
File Role Description
Files folder imageCommand (2 files)
Files folder imageModel (4 files)

  Files folder image Files  /  vendor  /  DP  /  Command  /  Command  
File Role Description
  Plain text file Buy.php Class Class source
  Plain text file Sell.php Class Class source

  Files folder image Files  /  vendor  /  DP  /  Command  /  Model  
File Role Description
  Plain text file Broker.php Class Class source
  Plain text file IStock.php Class Class source
  Plain text file Order.php Class Class source
  Plain text file Stock.php Class Class source

  Files folder image Files  /  vendor  /  DP  /  Facade  
File Role Description
Files folder imageModel (2 files)
Files folder imageService (5 files)
  Plain text file FacadeOrder.php Class Class source

  Files folder image Files  /  vendor  /  DP  /  Facade  /  Model  
File Role Description
  Plain text file Order.php Class Class source
  Plain text file Product.php Class Class source

  Files folder image Files  /  vendor  /  DP  /  Facade  /  Service  
File Role Description
  Plain text file Inventory.php Class Class source
  Plain text file OrderManager.php Class Class source
  Plain text file OrderServiceInterface.php Class Class source
  Plain text file Payment.php Class Class source
  Plain text file Shipping.php Class Class source

  Files folder image Files  /  vendor  /  DP  /  General  
File Role Description
  Plain text file Singleton.php Class Class source

  Files folder image Files  /  vendor  /  DP  /  Proxy  
File Role Description
Files folder imageModel (5 files)

  Files folder image Files  /  vendor  /  DP  /  Proxy  /  Model  
File Role Description
  Plain text file Cache.php Class Class source
  Plain text file Client.php Class Class source
  Plain text file ProxyServer.php Class Class source
  Plain text file ServerInterface.php Class Class source
  Plain text file WebServer.php Class Class source

  Files folder image Files  /  vendor  /  DP  /  Strategy  
File Role Description
Files folder imageModel (1 file)
Files folder imageStrategy (3 files)
Files folder imageView (1 file)

  Files folder image Files  /  vendor  /  DP  /  Strategy  /  Model  
File Role Description
  Plain text file ViewModel.php Class Class source

  Files folder image Files  /  vendor  /  DP  /  Strategy  /  Strategy  
File Role Description
  Plain text file JsonRenderingStrategy.php Class Class source
  Plain text file PhpRenderingStrategy.php Class Class source
  Plain text file RenderingStrategyInterface.php Class Class source

  Files folder image Files  /  vendor  /  DP  /  Strategy  /  View  
File Role Description
  Plain text file Renderer.php Class Class source

 Version Control Unique User Downloads Download Rankings  
 100%
Total:334
This week:1
All time:7,113
This week:560Up
 User Ratings  
 
 All time
Utility:93%StarStarStarStarStar
Consistency:100%StarStarStarStarStarStar
Documentation:93%StarStarStarStarStar
Examples:100%StarStarStarStarStarStar
Tests:-
Videos:-
Overall:76%StarStarStarStar
Rank:64