Completed
Push — v1.ns ( c7f51f...3baf09 )
by Timo
07:05
created

example.php ➔ convert()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 3
c 1
b 0
f 0
nc 1
nop 1
dl 0
loc 5
rs 9.4285
1
<?php
2
3
// please, change "<br>" to "\n" in the follwing line, when you run this file in the CLI
4
define('PEIP_LINE_SEPARATOR', "\n");
5
6
// This is PEIP�s (basic) way of the famous starbucks example from
7
// Gregor Hohpe http://www.eaipatterns.com/ramblings/18_starbucks.html 
8
9
// Note since this example works in a single threaded environment it 
10
// processes the orders in a synchronous way - every order is placed,
11
// prepared and delivered one after the other. 
12
// How to avoid this behavior will be shown in further examples.
13
 
14
15
// requiring autoloader
16
require_once(dirname(__FILE__).'/misc/bootstrap.php');
17
18
19
$context = PEIP\Context\XMLContext::createFromFile(dirname(__FILE__).'/config/config.xml'); 
20
$cafe = $context->getGateway('CafeGateway');
0 ignored issues
show
Deprecated Code introduced by
The method PEIP\Context\XMLContext::getGateway() has been deprecated.

This method has been deprecated.

Loading history...
21
22
// this would be the same done by scripting.
0 ignored issues
show
Unused Code Comprehensibility introduced by
48% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
23
/* ==
24
 * $registry = new PEIP_Channel_Registry;
25
 * $orders = new PEIP_Publish_Subscribe_Channel('orders');
26
 * $preparedDrinks = new PEIP_Publish_Subscribe_Channel('preparedDrinks');
27
 * $coldDrinks = new PEIP_Pollable_Channel('coldDrinks');
28
 * $registry->register($coldDrinks);
29
 * $hotDrinks = new PEIP_Pollable_Channel('hotDrinks');
30
 * $registry->register($hotDrinks);
31
 * $deliveries = new PEIP_Pollable_Channel('deliveries');
32
 * $cafeGateway = new CafeGateway($orders, $deliveries);
33
 * $orderWiretap = PEIP_Wiretap($orders);
34
 * $orderSplitter = new OrderSplitter($orders);
35
 * $router = new DrinkRouter($orderSplitter);
36
 * $barista = new Barista;
37
 * $coldDrinksActivator = new PEIP_Service_Activator(array($barista, 'prepareColdDrink'), $coldDrinks, $preparedDrinks);
38
 * $hotDrinksActivator = new PEIP_Service_Activator(array($barista, 'prepareHotDrink'), $hotDrinks, $preparedDrinks);
39
 * $drinkAggregator = new DrinkAggregator($preparedDrinks);
40
 * $aggregatorActivator = new PEIP_Service_Activator(array($drinkAggregator, 'receiveOrder'), $orderWiretap);
41
 * $waiter = new Waiter;
42
 * $waiterActivator = new PEIP_Service_Activator(array($waiter, 'prepareDelivery'), $drinkAggregator, $deliveries);
43
 * $cafe = $cafeGateway;
44
 */
45
46
47
if($cafe){
48
49
	for ($i = 1; $i <= 10; $i++) {
50
       	// create and place orders
51
		$order = new Order();
52
        	$order->addItem("LATTE", 2, false);
53
        	$order->addItem("MOCCA", 3, true);
54
        	$cafe->placeOrder($order);
55
        	// receive drinks
56
		$drinks = $cafe->receiveDelivery();
57
                var_dump($drinks);
58
    	}	
59
60
}else{
61
	throw new RuntimeException('Could not get CafeGateway');
62
}
63
64
65
66
67