@@ -11,7 +11,7 @@ |
||
11 | 11 | * |
12 | 12 | * @author timo |
13 | 13 | */ |
14 | -use PEIP\Event\EventBuilder; |
|
14 | +use PEIP\Event\EventBuilder; |
|
15 | 15 | use PEIP\Util\ReflectionPool; |
16 | 16 | |
17 | 17 | class EventClassDispatcher |
@@ -32,9 +32,9 @@ discard block |
||
32 | 32 | $this->getListeners( |
33 | 33 | $name, |
34 | 34 | $object |
35 | - ), |
|
36 | - $object->getContent() |
|
37 | - ); |
|
35 | + ), |
|
36 | + $object->getContent() |
|
37 | + ); |
|
38 | 38 | }else{ |
39 | 39 | throw new \InvalidArgumentException('instance of \PEIP\INF\Event\Event must contain subject'); |
40 | 40 | } |
@@ -43,18 +43,18 @@ discard block |
||
43 | 43 | } |
44 | 44 | } //put your code here |
45 | 45 | |
46 | - /** |
|
47 | - * Creates an event-object with given object as content/subject and notifies |
|
48 | - * all registers listeners of the event. |
|
49 | - * |
|
50 | - * @access public |
|
51 | - * @param string $name name of the event |
|
52 | - * @param object $object the subject of the event |
|
53 | - * @param array $headers headers of the event-object as key/value pairs |
|
54 | - * @param string $eventClass event-class to create instances from |
|
55 | - * @return |
|
56 | - * @see EventBuilder |
|
57 | - */ |
|
46 | + /** |
|
47 | + * Creates an event-object with given object as content/subject and notifies |
|
48 | + * all registers listeners of the event. |
|
49 | + * |
|
50 | + * @access public |
|
51 | + * @param string $name name of the event |
|
52 | + * @param object $object the subject of the event |
|
53 | + * @param array $headers headers of the event-object as key/value pairs |
|
54 | + * @param string $eventClass event-class to create instances from |
|
55 | + * @return |
|
56 | + * @see EventBuilder |
|
57 | + */ |
|
58 | 58 | public function buildAndNotify($name, $object, array $headers = array(), $eventClass = false, $type = false){ |
59 | 59 | if(!$this->hasListeners($name, ($object))){ |
60 | 60 | return false; |
@@ -11,8 +11,8 @@ |
||
11 | 11 | * |
12 | 12 | * @author timo |
13 | 13 | */ |
14 | -use PEIP\Util\Test; |
|
15 | -use PEIP\Base\GenericBuilder; |
|
14 | +use PEIP\Util\Test; |
|
15 | +use PEIP\Base\GenericBuilder; |
|
16 | 16 | use PEIP\Context\XMLContext; |
17 | 17 | |
18 | 18 | class ServiceFactory { |
@@ -16,13 +16,13 @@ discard block |
||
16 | 16 | use PEIP\Context\XMLContext; |
17 | 17 | |
18 | 18 | class ServiceFactory { |
19 | - /** |
|
20 | - * Creates and initializes service instance from a given configuration. |
|
21 | - * |
|
22 | - * @access public |
|
23 | - * @param $config configuration of the service |
|
24 | - * @return object the initialized service instance |
|
25 | - */ |
|
19 | + /** |
|
20 | + * Creates and initializes service instance from a given configuration. |
|
21 | + * |
|
22 | + * @access public |
|
23 | + * @param $config configuration of the service |
|
24 | + * @return object the initialized service instance |
|
25 | + */ |
|
26 | 26 | public static function createService(array $config){ |
27 | 27 | $args = array(); |
28 | 28 | //build arguments for constructor |
@@ -35,15 +35,15 @@ discard block |
||
35 | 35 | } |
36 | 36 | |
37 | 37 | /** |
38 | - * Builds an arbitrary service/object instance from a config-obect. |
|
39 | - * |
|
40 | - * @static |
|
41 | - * @access protected |
|
42 | - * @param object $config configuration object to build a service instance from. |
|
43 | - * @param array $arguments arguments for the service constructor |
|
44 | - * @param string $defaultClass class to create instance for if none is set in config |
|
45 | - * @return object build and modified srvice instance |
|
46 | - */ |
|
38 | + * Builds an arbitrary service/object instance from a config-obect. |
|
39 | + * |
|
40 | + * @static |
|
41 | + * @access protected |
|
42 | + * @param object $config configuration object to build a service instance from. |
|
43 | + * @param array $arguments arguments for the service constructor |
|
44 | + * @param string $defaultClass class to create instance for if none is set in config |
|
45 | + * @return object build and modified srvice instance |
|
46 | + */ |
|
47 | 47 | public static function doBuild($config, $arguments, $defaultClass = false){ |
48 | 48 | $cls = isset($config["class"]) ? trim((string)$config["class"]) : (string)$defaultClass; |
49 | 49 | if($cls != ''){ |
@@ -80,12 +80,12 @@ discard block |
||
80 | 80 | } |
81 | 81 | |
82 | 82 | /** |
83 | - * Builds single argument (to call a method with later) from a config-obect. |
|
84 | - * |
|
85 | - * @access protected |
|
86 | - * @param object $config configuration object to create argument from. |
|
87 | - * @return mixed build argument |
|
88 | - */ |
|
83 | + * Builds single argument (to call a method with later) from a config-obect. |
|
84 | + * |
|
85 | + * @access protected |
|
86 | + * @param object $config configuration object to create argument from. |
|
87 | + * @return mixed build argument |
|
88 | + */ |
|
89 | 89 | protected function buildArg($config){ |
90 | 90 | if(trim((string)$config['value']) != ''){ |
91 | 91 | $arg = (string)$config['value']; |
@@ -128,7 +128,7 @@ discard block |
||
128 | 128 | */ |
129 | 129 | public static function buildAndModify(array $config, $arguments, $defaultClass = ""){ |
130 | 130 | if((isset($config["class"]) && "" != (string)$config["class"]) || $defaultClass !== ""){ |
131 | - $service = ServiceFactory::doBuild($config, $arguments, $defaultClass); |
|
131 | + $service = ServiceFactory::doBuild($config, $arguments, $defaultClass); |
|
132 | 132 | }else{ |
133 | 133 | throw new \RuntimeException('Could not create Service. no class or reference given.'); |
134 | 134 | } |
@@ -20,7 +20,7 @@ |
||
20 | 20 | * @implements \PEIP\INF\Base\Container, \PEIP\INF\Message\Message, \PEIP\INF\Base\Buildable |
21 | 21 | */ |
22 | 22 | |
23 | -use PEIP\Util\Test; |
|
23 | +use PEIP\Util\Test; |
|
24 | 24 | use PEIP\Base\GenericBuilder; |
25 | 25 | |
26 | 26 | class GenericMessage |
@@ -76,11 +76,11 @@ |
||
76 | 76 | } |
77 | 77 | |
78 | 78 | /** |
79 | - * returns all headers of the message |
|
80 | - * |
|
81 | - * @access public |
|
82 | - * @return ArrayAccess ArrayAccess object of headers |
|
83 | - */ |
|
79 | + * returns all headers of the message |
|
80 | + * |
|
81 | + * @access public |
|
82 | + * @return ArrayAccess ArrayAccess object of headers |
|
83 | + */ |
|
84 | 84 | public function getHeaders(){ |
85 | 85 | return (array) $this->headers; |
86 | 86 | } |
@@ -11,7 +11,7 @@ |
||
11 | 11 | * |
12 | 12 | * @author timo |
13 | 13 | */ |
14 | -use PEIP\Context\XMLContext; |
|
14 | +use PEIP\Context\XMLContext; |
|
15 | 15 | use PEIP\Plugins\BasePlugin; |
16 | 16 | |
17 | 17 | class ServiceProvider extends \PEIP\Service\ServiceContainer { |
@@ -63,17 +63,17 @@ discard block |
||
63 | 63 | } |
64 | 64 | |
65 | 65 | /** |
66 | - * Registers a callable as builder for given node-name |
|
67 | - * |
|
68 | - * @implements \PEIP\INF\Context\Context |
|
69 | - * @access public |
|
70 | - * @param string $nodeName the name of the node |
|
71 | - * @param callable $callable a callable which creates instances for node-name |
|
72 | - */ |
|
66 | + * Registers a callable as builder for given node-name |
|
67 | + * |
|
68 | + * @implements \PEIP\INF\Context\Context |
|
69 | + * @access public |
|
70 | + * @param string $nodeName the name of the node |
|
71 | + * @param callable $callable a callable which creates instances for node-name |
|
72 | + */ |
|
73 | 73 | public function registerNodeBuilder($nodeName, $callable){ |
74 | 74 | $this->nodeBuilders[$nodeName] = $callable; |
75 | 75 | } |
76 | - /** |
|
76 | + /** |
|
77 | 77 | * Registers the build-methods for the main-components with this context. |
78 | 78 | * Note: This method and subsequent registered methods of this class are |
79 | 79 | * candidates for refactoring. Because this class has grown much to large |
@@ -89,7 +89,7 @@ discard block |
||
89 | 89 | ); |
90 | 90 | $plugin = new BasePlugin(); |
91 | 91 | foreach($builders as $nodeName => $method){ |
92 | - $this->registerNodeBuilder($nodeName, array($this, $method)); |
|
92 | + $this->registerNodeBuilder($nodeName, array($this, $method)); |
|
93 | 93 | } |
94 | 94 | } |
95 | 95 |
@@ -31,19 +31,19 @@ |
||
31 | 31 | } |
32 | 32 | |
33 | 33 | protected function prepareDrink($orderNumber, $type, $iced){ |
34 | - $drink = new Drink($orderNumber, $type, $iced); |
|
35 | - return $drink; |
|
34 | + $drink = new Drink($orderNumber, $type, $iced); |
|
35 | + return $drink; |
|
36 | 36 | } |
37 | 37 | |
38 | 38 | protected function printAction($cold, $orderNr){ |
39 | - if($cold){ |
|
40 | - $type = 'cold'; |
|
41 | - $count = $this->coldDrinkCounter; |
|
42 | - }else{ |
|
43 | - $type = 'hot'; |
|
44 | - $count = $this->hotDrinkCounter; |
|
45 | - } |
|
46 | - $total = $this->coldDrinkCounter + $this->hotDrinkCounter; |
|
39 | + if($cold){ |
|
40 | + $type = 'cold'; |
|
41 | + $count = $this->coldDrinkCounter; |
|
42 | + }else{ |
|
43 | + $type = 'hot'; |
|
44 | + $count = $this->hotDrinkCounter; |
|
45 | + } |
|
46 | + $total = $this->coldDrinkCounter + $this->hotDrinkCounter; |
|
47 | 47 | echo PEIP_LINE_SEPARATOR."Barista: prepared $type drink (total #$total- $type #$count) for order #$orderNr"; |
48 | 48 | flush(); |
49 | 49 | } |
@@ -2,40 +2,40 @@ |
||
2 | 2 | |
3 | 3 | class Order { |
4 | 4 | |
5 | - protected |
|
6 | - $items = array(), |
|
7 | - $orderNumber; |
|
8 | - protected static $orderCount = 0; |
|
5 | + protected |
|
6 | + $items = array(), |
|
7 | + $orderNumber; |
|
8 | + protected static $orderCount = 0; |
|
9 | 9 | |
10 | - public function __construct(){ |
|
11 | - self::$orderCount++; |
|
12 | - $this->orderNumber = self::$orderCount; |
|
13 | - } |
|
10 | + public function __construct(){ |
|
11 | + self::$orderCount++; |
|
12 | + $this->orderNumber = self::$orderCount; |
|
13 | + } |
|
14 | 14 | |
15 | - public function getOrderNumber(){ |
|
16 | - return $this->orderNumber; |
|
17 | - } |
|
15 | + public function getOrderNumber(){ |
|
16 | + return $this->orderNumber; |
|
17 | + } |
|
18 | 18 | |
19 | - public function addItem($type, $number, $iced = false){ |
|
20 | - $this->items[] = |
|
21 | - array( |
|
22 | - 'type' => $type, |
|
23 | - 'number' => $number, |
|
24 | - 'iced' => $iced |
|
25 | - ); |
|
26 | - } |
|
19 | + public function addItem($type, $number, $iced = false){ |
|
20 | + $this->items[] = |
|
21 | + array( |
|
22 | + 'type' => $type, |
|
23 | + 'number' => $number, |
|
24 | + 'iced' => $iced |
|
25 | + ); |
|
26 | + } |
|
27 | 27 | |
28 | - public function getItems(){ |
|
29 | - return $this->items; |
|
30 | - } |
|
28 | + public function getItems(){ |
|
29 | + return $this->items; |
|
30 | + } |
|
31 | 31 | |
32 | - public function getTotalCount(){ |
|
33 | - $x = 0; |
|
34 | - foreach($this->items as $item){ |
|
35 | - $x += (int)$item['number']; |
|
36 | - } |
|
37 | - return $x; |
|
38 | - } |
|
32 | + public function getTotalCount(){ |
|
33 | + $x = 0; |
|
34 | + foreach($this->items as $item){ |
|
35 | + $x += (int)$item['number']; |
|
36 | + } |
|
37 | + return $x; |
|
38 | + } |
|
39 | 39 | |
40 | 40 | |
41 | 41 |
@@ -2,14 +2,14 @@ |
||
2 | 2 | |
3 | 3 | class Delivery { |
4 | 4 | |
5 | - protected |
|
6 | - $deliveredDrinks, |
|
7 | - $orderNumber; |
|
5 | + protected |
|
6 | + $deliveredDrinks, |
|
7 | + $orderNumber; |
|
8 | 8 | |
9 | - public function __construct(array $deliveredDrinks){ |
|
10 | - $this->deliveredDrinks = $deliveredDrinks; |
|
11 | - $this->orderNumber = $deliveredDrinks[0]->getOrderNumber(); |
|
12 | - } |
|
9 | + public function __construct(array $deliveredDrinks){ |
|
10 | + $this->deliveredDrinks = $deliveredDrinks; |
|
11 | + $this->orderNumber = $deliveredDrinks[0]->getOrderNumber(); |
|
12 | + } |
|
13 | 13 | |
14 | 14 | |
15 | 15 |
@@ -3,30 +3,30 @@ |
||
3 | 3 | |
4 | 4 | class Drink { |
5 | 5 | |
6 | - protected |
|
7 | - $orderNumber, |
|
8 | - $type, |
|
9 | - $iced; |
|
6 | + protected |
|
7 | + $orderNumber, |
|
8 | + $type, |
|
9 | + $iced; |
|
10 | 10 | |
11 | - public function __construct($orderNumber, $type, $iced){ |
|
12 | - $this->orderNumber = $orderNumber; |
|
13 | - $this->type = $type; |
|
14 | - $this->iced = $iced; |
|
15 | - } |
|
11 | + public function __construct($orderNumber, $type, $iced){ |
|
12 | + $this->orderNumber = $orderNumber; |
|
13 | + $this->type = $type; |
|
14 | + $this->iced = $iced; |
|
15 | + } |
|
16 | 16 | |
17 | - public function getType(){ |
|
18 | - return $this->type; |
|
19 | - } |
|
17 | + public function getType(){ |
|
18 | + return $this->type; |
|
19 | + } |
|
20 | 20 | |
21 | - public function getIced(){ |
|
22 | - return $this->iced; |
|
23 | - } |
|
21 | + public function getIced(){ |
|
22 | + return $this->iced; |
|
23 | + } |
|
24 | 24 | |
25 | - public function getOrderNumber(){ |
|
26 | - return $this->orderNumber; |
|
27 | - } |
|
25 | + public function getOrderNumber(){ |
|
26 | + return $this->orderNumber; |
|
27 | + } |
|
28 | 28 | |
29 | - public function __sleep() |
|
29 | + public function __sleep() |
|
30 | 30 | { |
31 | 31 | return array('orderNumber', 'type', 'iced'); |
32 | 32 | } |
@@ -2,11 +2,11 @@ |
||
2 | 2 | |
3 | 3 | class DrinkType { |
4 | 4 | |
5 | - const |
|
6 | - ESPRESSO = 'ESPRESSO', |
|
7 | - LATTE = 'LATTE', |
|
8 | - CAPPUCCINO = 'CAPPUCCINO', |
|
9 | - MOCCA = 'MOCCA'; |
|
5 | + const |
|
6 | + ESPRESSO = 'ESPRESSO', |
|
7 | + LATTE = 'LATTE', |
|
8 | + CAPPUCCINO = 'CAPPUCCINO', |
|
9 | + MOCCA = 'MOCCA'; |
|
10 | 10 | |
11 | 11 | } |
12 | 12 |