PHP Classes

Design patterns: Implements several well known design patterns

Recommend this page to a friend!
     
  Info   Example   View files Files   Install with Composer Install with Composer   Download Download   Reputation   Support forum   Blog    
Ratings Unique User Downloads Download Rankings
StarStarStarStar 76%Total: 334 All time: 7,121 This week: 53Up
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  
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 (43)  
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

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:334
This week:0
All time:7,121
This week:53Up
 User Ratings  
 
 All time
Utility:93%StarStarStarStarStar
Consistency:100%StarStarStarStarStarStar
Documentation:93%StarStarStarStarStar
Examples:100%StarStarStarStarStarStar
Tests:-
Videos:-
Overall:76%StarStarStarStar
Rank:64