@@ -46,19 +46,19 @@ |
||
| 46 | 46 | |
| 47 | 47 | if($cafe){
|
| 48 | 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(); |
|
| 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 | 57 | var_dump($drinks); |
| 58 | - } |
|
| 58 | + } |
|
| 59 | 59 | |
| 60 | 60 | }else{
|
| 61 | - throw new RuntimeException('Could not get CafeGateway');
|
|
| 61 | + throw new RuntimeException('Could not get CafeGateway');
|
|
| 62 | 62 | } |
| 63 | 63 | |
| 64 | 64 | |
@@ -57,7 +57,7 @@ |
||
| 57 | 57 | |
| 58 | 58 | } |
| 59 | 59 | |
| 60 | -} else {
|
|
| 60 | +}else {
|
|
| 61 | 61 | throw new RuntimeException('Could not get CafeGateway');
|
| 62 | 62 | } |
| 63 | 63 | |
@@ -4,14 +4,14 @@ |
||
| 4 | 4 | use PEIP\INF\Message\Message; |
| 5 | 5 | |
| 6 | 6 | class DrinkRouter |
| 7 | - extends Router {
|
|
| 7 | + extends Router {
|
|
| 8 | 8 | |
| 9 | - protected function selectChannels(Message $message){
|
|
| 10 | - $order = $message->getContent(); |
|
| 11 | - $channelName = $order['iced'] ? 'coldDrinks' : 'hotDrinks'; |
|
| 12 | - echo PEIP_LINE_SEPARATOR."DrinkRouter: routed to channel: $channelName"; |
|
| 13 | - return $channelName; |
|
| 14 | - } |
|
| 9 | + protected function selectChannels(Message $message){
|
|
| 10 | + $order = $message->getContent(); |
|
| 11 | + $channelName = $order['iced'] ? 'coldDrinks' : 'hotDrinks'; |
|
| 12 | + echo PEIP_LINE_SEPARATOR."DrinkRouter: routed to channel: $channelName"; |
|
| 13 | + return $channelName; |
|
| 14 | + } |
|
| 15 | 15 | |
| 16 | 16 | |
| 17 | 17 | } |
@@ -6,9 +6,9 @@ |
||
| 6 | 6 | class DrinkRouter |
| 7 | 7 | extends Router {
|
| 8 | 8 | |
| 9 | - protected function selectChannels(Message $message){
|
|
| 9 | + protected function selectChannels(Message $message) {
|
|
| 10 | 10 | $order = $message->getContent(); |
| 11 | - $channelName = $order['iced'] ? 'coldDrinks' : 'hotDrinks'; |
|
| 11 | + $channelName = $order['iced'] ? 'coldDrinks' : 'hotDrinks'; |
|
| 12 | 12 | echo PEIP_LINE_SEPARATOR."DrinkRouter: routed to channel: $channelName"; |
| 13 | 13 | return $channelName; |
| 14 | 14 | } |
@@ -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 | } |
@@ -51,7 +51,7 @@ discard block |
||
| 51 | 51 | $constructor = isset($config["constructor"]) ? (string)$config["constructor"] : ""; |
| 52 | 52 | if ($constructor != '' && Test::assertMethod($cls, $constructor)) {
|
| 53 | 53 | $service = call_user_func_array(array($cls, $constructor), $arguments); |
| 54 | - } else {
|
|
| 54 | + }else {
|
|
| 55 | 55 | $service = self::build($cls, $arguments); |
| 56 | 56 | } |
| 57 | 57 | } catch (\Exception $e) {
|
@@ -97,7 +97,7 @@ discard block |
||
| 97 | 97 | if ($entry->getName() == 'value') {
|
| 98 | 98 | if ($entry['key']) {
|
| 99 | 99 | $arg[(string)$entry['key']] = (string)$entry; |
| 100 | - } else {
|
|
| 100 | + }else {
|
|
| 101 | 101 | $arg[] = (string)$entry; |
| 102 | 102 | } |
| 103 | 103 | } elseif ($entry->getName() == 'service') {
|
@@ -129,7 +129,7 @@ discard block |
||
| 129 | 129 | public static function buildAndModify(array $config, $arguments, $defaultClass = "") {
|
| 130 | 130 | if ((isset($config["class"]) && "" != (string)$config["class"]) || $defaultClass !== "") {
|
| 131 | 131 | $service = ServiceFactory::doBuild($config, $arguments, $defaultClass); |
| 132 | - } else {
|
|
| 132 | + }else {
|
|
| 133 | 133 | throw new \RuntimeException('Could not create Service. no class or reference given.');
|
| 134 | 134 | } |
| 135 | 135 | if (isset($config["ref_property"])) {
|
@@ -34,7 +34,7 @@ discard block |
||
| 34 | 34 | * @param mixed $value the value to store |
| 35 | 35 | * @return |
| 36 | 36 | */ |
| 37 | - public function setValue($key, $value){ |
|
| 37 | + public function setValue($key, $value) { |
|
| 38 | 38 | return $this->offsetSet($key, $value); |
| 39 | 39 | } |
| 40 | 40 | |
@@ -45,7 +45,7 @@ discard block |
||
| 45 | 45 | * @param mixed $key the key to return value for |
| 46 | 46 | * @return mixed the value for the given key |
| 47 | 47 | */ |
| 48 | - public function getValue($key){ |
|
| 48 | + public function getValue($key) { |
|
| 49 | 49 | return $this->offsetGet($key, $value); |
| 50 | 50 | } |
| 51 | 51 | |
@@ -56,7 +56,7 @@ discard block |
||
| 56 | 56 | * @param mixed $key the key to unset value for |
| 57 | 57 | * @return |
| 58 | 58 | */ |
| 59 | - public function deleteValue($key){ |
|
| 59 | + public function deleteValue($key) { |
|
| 60 | 60 | return $this->offsetUnset($key); |
| 61 | 61 | } |
| 62 | 62 | |
@@ -67,7 +67,7 @@ discard block |
||
| 67 | 67 | * @param mixed $key the key to look for a value |
| 68 | 68 | * @return boolean wether a value is stored for the key |
| 69 | 69 | */ |
| 70 | - public function hasValue($key){ |
|
| 70 | + public function hasValue($key) { |
|
| 71 | 71 | return $this->offsetExists($key); |
| 72 | 72 | } |
| 73 | 73 | |
@@ -78,7 +78,7 @@ discard block |
||
| 78 | 78 | * @param array $values key/value pairs to store |
| 79 | 79 | * @return |
| 80 | 80 | */ |
| 81 | - public function setValues(array $values){ |
|
| 81 | + public function setValues(array $values) { |
|
| 82 | 82 | $this->values = $values; |
| 83 | 83 | } |
| 84 | 84 | |
@@ -88,7 +88,7 @@ discard block |
||
| 88 | 88 | * @access public |
| 89 | 89 | * @return array stored key/value pairs |
| 90 | 90 | */ |
| 91 | - public function getValues(){ |
|
| 91 | + public function getValues() { |
|
| 92 | 92 | return $this->values; |
| 93 | 93 | } |
| 94 | 94 | |
@@ -100,7 +100,7 @@ discard block |
||
| 100 | 100 | * @param $values |
| 101 | 101 | * @return |
| 102 | 102 | */ |
| 103 | - public function addValues(array $values){ |
|
| 103 | + public function addValues(array $values) { |
|
| 104 | 104 | array_merge($this->values, $values); |
| 105 | 105 | } |
| 106 | 106 | } |
| 107 | 107 | \ No newline at end of file |
@@ -38,8 +38,8 @@ discard block |
||
| 38 | 38 | * @param string $eventName name of the event to listen to |
| 39 | 39 | * @param \PEIP\INF\Event\Connectable $connectable instance of \PEIP\INF\Event\Connectable to listen to |
| 40 | 40 | */ |
| 41 | - protected function doListen($eventName, \PEIP\INF\Event\Connectable $connectable){ |
|
| 42 | - if(!$connectable->hasListener($eventName, $this)){ |
|
| 41 | + protected function doListen($eventName, \PEIP\INF\Event\Connectable $connectable) { |
|
| 42 | + if (!$connectable->hasListener($eventName, $this)) { |
|
| 43 | 43 | $connectable->connect($eventName, $this); |
| 44 | 44 | $this->connections[spl_object_hash($connectable)] = $connectable; |
| 45 | 45 | } |
@@ -52,8 +52,8 @@ discard block |
||
| 52 | 52 | * @param string $eventName name of the event to unlisten |
| 53 | 53 | * @param \PEIP\INF\Event\Connectable $connectable instance of \PEIP\INF\Event\Connectable to unlisten to |
| 54 | 54 | */ |
| 55 | - protected function doUnlisten($eventName, \PEIP\INF\Event\Connectable $connectable){ |
|
| 56 | - if(!$connectable->hasListener($eventName, $this)){ |
|
| 55 | + protected function doUnlisten($eventName, \PEIP\INF\Event\Connectable $connectable) { |
|
| 56 | + if (!$connectable->hasListener($eventName, $this)) { |
|
| 57 | 57 | $connectable->disconnect($eventName, $this); |
| 58 | 58 | unset($this->connections[spl_object_hash($connectable)]); |
| 59 | 59 | } |
@@ -65,7 +65,7 @@ discard block |
||
| 65 | 65 | * @access public |
| 66 | 66 | * @return array array of \PEIP\INF\Event\Connectable instances |
| 67 | 67 | */ |
| 68 | - public function doGetConnected(){ |
|
| 68 | + public function doGetConnected() { |
|
| 69 | 69 | return array_values($this->connections); |
| 70 | 70 | } |
| 71 | 71 | |
@@ -35,9 +35,9 @@ discard block |
||
| 35 | 35 | * @param \PEIP\INF\Channel\Channel $outputChannel the outputs-channel |
| 36 | 36 | * @return |
| 37 | 37 | */ |
| 38 | - public function __construct(\PEIP\INF\Channel\Channel $inputChannel, \PEIP\INF\Channel\Channel $outputChannel = NULL){ |
|
| 38 | + public function __construct(\PEIP\INF\Channel\Channel $inputChannel, \PEIP\INF\Channel\Channel $outputChannel = NULL) { |
|
| 39 | 39 | $this->setInputChannel($inputChannel); |
| 40 | - if(is_object($outputChannel)){ |
|
| 40 | + if (is_object($outputChannel)) { |
|
| 41 | 41 | $this->setOutputChannel($outputChannel); |
| 42 | 42 | } |
| 43 | 43 | } |
@@ -49,13 +49,13 @@ discard block |
||
| 49 | 49 | * @param \PEIP\INF\Message\Message $message message to split |
| 50 | 50 | * @return |
| 51 | 51 | */ |
| 52 | - public function doReply(\PEIP\INF\Message\Message $message){ |
|
| 52 | + public function doReply(\PEIP\INF\Message\Message $message) { |
|
| 53 | 53 | $res = $this->split($message); |
| 54 | - if(is_array($res)){ |
|
| 55 | - foreach($res as $msg){ |
|
| 54 | + if (is_array($res)) { |
|
| 55 | + foreach ($res as $msg) { |
|
| 56 | 56 | $this->replyMessage($msg); |
| 57 | 57 | } |
| 58 | - }else{ |
|
| 58 | + }else { |
|
| 59 | 59 | $this->replyMessage($res); |
| 60 | 60 | } |
| 61 | 61 | } |
@@ -33,7 +33,7 @@ |
||
| 33 | 33 | * @param $outputChannel |
| 34 | 34 | * @return |
| 35 | 35 | */ |
| 36 | - public function __construct($eventName, \PEIP\INF\Channel\Channel $inputChannel, \PEIP\INF\Channel\Channel $outputChannel){ |
|
| 36 | + public function __construct($eventName, \PEIP\INF\Channel\Channel $inputChannel, \PEIP\INF\Channel\Channel $outputChannel) { |
|
| 37 | 37 | $this->setEventName($eventName); |
| 38 | 38 | $this->setInputChannel($inputChannel); |
| 39 | 39 | $this->setOutputChannel($outputChannel); |
@@ -47,7 +47,7 @@ discard block |
||
| 47 | 47 | * @param $type |
| 48 | 48 | * @return |
| 49 | 49 | */ |
| 50 | - public function __construct($type){ |
|
| 50 | + public function __construct($type) { |
|
| 51 | 51 | $this->type = $type; |
| 52 | 52 | } |
| 53 | 53 | |
@@ -57,7 +57,7 @@ discard block |
||
| 57 | 57 | * @param $message |
| 58 | 58 | * @return |
| 59 | 59 | */ |
| 60 | - public function acceptMessage(\PEIP\INF\Message\Message $message){ |
|
| 60 | + public function acceptMessage(\PEIP\INF\Message\Message $message) { |
|
| 61 | 61 | return call_user_func(self::$types[$this->type], $message->getContent()); |
| 62 | 62 | } |
| 63 | 63 | |
@@ -23,26 +23,26 @@ |
||
| 23 | 23 | |
| 24 | 24 | interface ParameterHolderCollection { |
| 25 | 25 | |
| 26 | - public function setParameters($namespace, array $parameters); |
|
| 26 | + public function setParameters($namespace, array $parameters); |
|
| 27 | 27 | |
| 28 | - public function addParameters($namespace, array $parameters); |
|
| 28 | + public function addParameters($namespace, array $parameters); |
|
| 29 | 29 | |
| 30 | - public function getParameters($namespace); |
|
| 30 | + public function getParameters($namespace); |
|
| 31 | 31 | |
| 32 | - public function getParameter($namespace, $name); |
|
| 32 | + public function getParameter($namespace, $name); |
|
| 33 | 33 | |
| 34 | - public function setParameter($namespace, $name, $value); |
|
| 34 | + public function setParameter($namespace, $name, $value); |
|
| 35 | 35 | |
| 36 | - public function hasParameter($namespace, $name); |
|
| 36 | + public function hasParameter($namespace, $name); |
|
| 37 | 37 | |
| 38 | - public function deleteParameter($namespace, $name); |
|
| 38 | + public function deleteParameter($namespace, $name); |
|
| 39 | 39 | |
| 40 | - public function setParameterHolder($namespace, \PEIP\INF\Data\ParameterHolder $holder); |
|
| 40 | + public function setParameterHolder($namespace, \PEIP\INF\Data\ParameterHolder $holder); |
|
| 41 | 41 | |
| 42 | - public function getParameterHolder($namespace); |
|
| 42 | + public function getParameterHolder($namespace); |
|
| 43 | 43 | |
| 44 | - public function hasParameterHolder($namespace); |
|
| 44 | + public function hasParameterHolder($namespace); |
|
| 45 | 45 | |
| 46 | - public function deleteParameterHolder($namespace); |
|
| 46 | + public function deleteParameterHolder($namespace); |
|
| 47 | 47 | |
| 48 | 48 | } |
| 49 | 49 | \ No newline at end of file |