| @@ -30,16 +30,16 @@ | ||
| 30 | 30 | return $this->prepareDrink($orderItem['order'], $orderItem['type'], true); | 
| 31 | 31 | } | 
| 32 | 32 | |
| 33 | -    protected function prepareDrink($orderNumber, $type, $iced){ | |
| 33 | +    protected function prepareDrink($orderNumber, $type, $iced) { | |
| 34 | 34 | $drink = new Drink($orderNumber, $type, $iced); | 
| 35 | 35 | return $drink; | 
| 36 | 36 | } | 
| 37 | 37 | |
| 38 | -    protected function printAction($cold, $orderNr){ | |
| 39 | -    	if($cold){ | |
| 38 | +    protected function printAction($cold, $orderNr) { | |
| 39 | +    	if ($cold) { | |
| 40 | 40 | $type = 'cold'; | 
| 41 | 41 | $count = $this->coldDrinkCounter; | 
| 42 | -    	}else{ | |
| 42 | +    	}else { | |
| 43 | 43 | $type = 'hot'; | 
| 44 | 44 | $count = $this->hotDrinkCounter; | 
| 45 | 45 | } | 
| @@ -39,7 +39,7 @@ | ||
| 39 | 39 |      	if($cold){ | 
| 40 | 40 | $type = 'cold'; | 
| 41 | 41 | $count = $this->coldDrinkCounter; | 
| 42 | -    	}else{ | |
| 42 | +    	} else{ | |
| 43 | 43 | $type = 'hot'; | 
| 44 | 44 | $count = $this->hotDrinkCounter; | 
| 45 | 45 | } | 
| @@ -7,16 +7,16 @@ discard block | ||
| 7 | 7 | $orderNumber; | 
| 8 | 8 | protected static $orderCount = 0; | 
| 9 | 9 | |
| 10 | -	public function __construct(){ | |
| 10 | +	public function __construct() { | |
| 11 | 11 | self::$orderCount++; | 
| 12 | 12 | $this->orderNumber = self::$orderCount; | 
| 13 | 13 | } | 
| 14 | 14 | |
| 15 | -	public function getOrderNumber(){ | |
| 15 | +	public function getOrderNumber() { | |
| 16 | 16 | return $this->orderNumber; | 
| 17 | 17 | } | 
| 18 | 18 | |
| 19 | -	public function addItem($type, $number, $iced = false){ | |
| 19 | +	public function addItem($type, $number, $iced = false) { | |
| 20 | 20 | $this->items[] = | 
| 21 | 21 | array( | 
| 22 | 22 | 'type' => $type, | 
| @@ -25,13 +25,13 @@ discard block | ||
| 25 | 25 | ); | 
| 26 | 26 | } | 
| 27 | 27 | |
| 28 | -	public function getItems(){ | |
| 28 | +	public function getItems() { | |
| 29 | 29 | return $this->items; | 
| 30 | 30 | } | 
| 31 | 31 | |
| 32 | -	public function getTotalCount(){ | |
| 32 | +	public function getTotalCount() { | |
| 33 | 33 | $x = 0; | 
| 34 | -		foreach($this->items as $item){ | |
| 34 | +		foreach ($this->items as $item) { | |
| 35 | 35 | $x += (int)$item['number']; | 
| 36 | 36 | } | 
| 37 | 37 | return $x; | 
| @@ -6,7 +6,7 @@ | ||
| 6 | 6 | $deliveredDrinks, | 
| 7 | 7 | $orderNumber; | 
| 8 | 8 | |
| 9 | -	public function __construct(array $deliveredDrinks){ | |
| 9 | +	public function __construct(array $deliveredDrinks) { | |
| 10 | 10 | $this->deliveredDrinks = $deliveredDrinks; | 
| 11 | 11 | $this->orderNumber = $deliveredDrinks[0]->getOrderNumber(); | 
| 12 | 12 | } | 
| @@ -8,21 +8,21 @@ | ||
| 8 | 8 | $type, | 
| 9 | 9 | $iced; | 
| 10 | 10 | |
| 11 | -	public function __construct($orderNumber, $type, $iced){ | |
| 11 | +	public function __construct($orderNumber, $type, $iced) { | |
| 12 | 12 | $this->orderNumber = $orderNumber; | 
| 13 | 13 | $this->type = $type; | 
| 14 | 14 | $this->iced = $iced; | 
| 15 | 15 | } | 
| 16 | 16 | |
| 17 | -	public function getType(){ | |
| 17 | +	public function getType() { | |
| 18 | 18 | return $this->type; | 
| 19 | 19 | } | 
| 20 | 20 | |
| 21 | -	public function getIced(){ | |
| 21 | +	public function getIced() { | |
| 22 | 22 | return $this->iced; | 
| 23 | 23 | } | 
| 24 | 24 | |
| 25 | -	public function getOrderNumber(){ | |
| 25 | +	public function getOrderNumber() { | |
| 26 | 26 | return $this->orderNumber; | 
| 27 | 27 | } | 
| 28 | 28 | |
| @@ -5,18 +5,18 @@ | ||
| 5 | 5 | |
| 6 | 6 | protected $orders; | 
| 7 | 7 | |
| 8 | -	public function prepareDelivery(array $drinks){ | |
| 8 | +	public function prepareDelivery(array $drinks) { | |
| 9 | 9 | echo PEIP_LINE_SEPARATOR.'Waiter: prepareDelivery: #'.$drinks[0]->getOrderNumber(); | 
| 10 | 10 | return new Delivery($drinks); | 
| 11 | 11 | } | 
| 12 | 12 | |
| 13 | 13 | |
| 14 | -	public function receiveOrder(Order $order){ | |
| 14 | +	public function receiveOrder(Order $order) { | |
| 15 | 15 | echo PEIP_LINE_SEPARATOR.'Waiter: receiveOrder'; | 
| 16 | 16 | $this->orders[$order->getOrderNumber()] = $order; | 
| 17 | 17 | } | 
| 18 | 18 | |
| 19 | -	public function getOrder($nr){ | |
| 19 | +	public function getOrder($nr) { | |
| 20 | 20 | return $this->orders[$nr]; | 
| 21 | 21 | } | 
| 22 | 22 | |
| @@ -27,9 +27,9 @@ discard block | ||
| 27 | 27 | * @param Callable|PEIP\INF\Handler\Handler $listener event-handler | 
| 28 | 28 | * @return boolean | 
| 29 | 29 | */ | 
| 30 | -    public function connect($name, $object, $listener){ 
 | |
| 30 | +    public function connect($name, $object, $listener) { 
 | |
| 31 | 31 | $class = is_object($object) ? get_class($object) : (string)$object; | 
| 32 | -        foreach(Reflection::getImplementedClassesAndInterfaces($object) as $cls){
 | |
| 32 | +        foreach (Reflection::getImplementedClassesAndInterfaces($object) as $cls) {
 | |
| 33 | 33 | $reflection = Reflection_Pool::getInstance($class); | 
| 34 | 34 | parent::connect($name, $reflection, $listener); | 
| 35 | 35 | } | 
| @@ -37,13 +37,13 @@ discard block | ||
| 37 | 37 | return true; | 
| 38 | 38 | } | 
| 39 | 39 | |
| 40 | -    public function disconnect($name, $object, $listener){
 | |
| 40 | +    public function disconnect($name, $object, $listener) {
 | |
| 41 | 41 | $class = is_object($object) ? get_class($object) : (string)$object; | 
| 42 | 42 | $res = true; | 
| 43 | -        foreach(Reflection::getImplementedClassesAndInterfaces($object) as $cls){
 | |
| 43 | +        foreach (Reflection::getImplementedClassesAndInterfaces($object) as $cls) {
 | |
| 44 | 44 | $reflection = Reflection_Pool::getInstance($class); | 
| 45 | 45 | $r = parent::disconnect($name, $reflection, $listener); | 
| 46 | -            if(!$r){
 | |
| 46 | +            if (!$r) {
 | |
| 47 | 47 | $res = false; | 
| 48 | 48 | } | 
| 49 | 49 | } | 
| @@ -58,9 +58,9 @@ discard block | ||
| 58 | 58 | * @param \PEIP\INF\Event\Event $object an event object | 
| 59 | 59 | * @return boolean | 
| 60 | 60 | */ | 
| 61 | -    public function notify($name, $object){ 
 | |
| 62 | -        if($object instanceof \PEIP\INF\Event\Event){
 | |
| 63 | -            if(is_object($object->getContent())){
 | |
| 61 | +    public function notify($name, $object) { 
 | |
| 62 | +        if ($object instanceof \PEIP\INF\Event\Event) {
 | |
| 63 | +            if (is_object($object->getContent())) {
 | |
| 64 | 64 | return self::doNotify( | 
| 65 | 65 | $this->getListeners( | 
| 66 | 66 | $name, | 
| @@ -70,10 +70,10 @@ discard block | ||
| 70 | 70 | ), | 
| 71 | 71 | $object | 
| 72 | 72 | ); | 
| 73 | -            }else{
 | |
| 73 | +            }else {
 | |
| 74 | 74 |                  throw new \InvalidArgumentException('instance of \PEIP\INF\Event\Event must contain subject');
 | 
| 75 | 75 | } | 
| 76 | -        }else{
 | |
| 76 | +        }else {
 | |
| 77 | 77 |              throw new \InvalidArgumentException('object must be instance of \PEIP\INF\Event\Event');
 | 
| 78 | 78 | } | 
| 79 | 79 | } //put your code here | 
| @@ -90,8 +90,8 @@ discard block | ||
| 90 | 90 | * @return | 
| 91 | 91 | * @see EventBuilder | 
| 92 | 92 | */ | 
| 93 | -    public function buildAndNotify($name, $object, array $headers = array(), $eventClass = false, $type = false){
 | |
| 94 | -        if(!$this->hasListeners($name, ($object))){
 | |
| 93 | +    public function buildAndNotify($name, $object, array $headers = array(), $eventClass = false, $type = false) {
 | |
| 94 | +        if (!$this->hasListeners($name, ($object))) {
 | |
| 95 | 95 | return false; | 
| 96 | 96 | } | 
| 97 | 97 | |
| @@ -114,7 +114,7 @@ discard block | ||
| 114 | 114 | * @param object $object object to check for listeners | 
| 115 | 115 | * @return boolean | 
| 116 | 116 | */ | 
| 117 | -    public function hasListeners($name, $object){
 | |
| 117 | +    public function hasListeners($name, $object) {
 | |
| 118 | 118 | return parent::hasListeners( | 
| 119 | 119 | $name, | 
| 120 | 120 | Reflection_Pool::getInstance($object) | 
| @@ -70,10 +70,10 @@ | ||
| 70 | 70 | ), | 
| 71 | 71 | $object | 
| 72 | 72 | ); | 
| 73 | -            }else{
 | |
| 73 | +            } else{
 | |
| 74 | 74 |                  throw new \InvalidArgumentException('instance of \PEIP\INF\Event\Event must contain subject');
 | 
| 75 | 75 | } | 
| 76 | -        }else{
 | |
| 76 | +        } else{
 | |
| 77 | 77 |              throw new \InvalidArgumentException('object must be instance of \PEIP\INF\Event\Event');
 | 
| 78 | 78 | } | 
| 79 | 79 | } //put your code here | 
| @@ -43,10 +43,10 @@ discard block | ||
| 43 | 43 | * @param boolean $storeRef wether to store a reference for new instance. default: true | 
| 44 | 44 | * @return | 
| 45 | 45 | */ | 
| 46 | -    public function __construct($className, \ReflectionClass $reflectionClass = NULL, $storeRef = true){ | |
| 47 | -        if($reflectionClass ){ | |
| 46 | +    public function __construct($className, \ReflectionClass $reflectionClass = NULL, $storeRef = true) { | |
| 47 | +        if ($reflectionClass) { | |
| 48 | 48 | |
| 49 | -            if($reflectionClass->getName() != $className){ | |
| 49 | +            if ($reflectionClass->getName() != $className) { | |
| 50 | 50 | throw new \Exception( | 
| 51 | 51 | 'Constructing GenericBuilder with wrong ReflectionClass' | 
| 52 | 52 | ); | 
| @@ -56,7 +56,7 @@ discard block | ||
| 56 | 56 | $this->reflectionClass = $reflectionClass; | 
| 57 | 57 | } | 
| 58 | 58 | $this->className = $className; | 
| 59 | -        if($storeRef){ | |
| 59 | +        if ($storeRef) { | |
| 60 | 60 | self::$instances[$this->className] = $this; | 
| 61 | 61 | } | 
| 62 | 62 | } | 
| @@ -68,8 +68,8 @@ discard block | ||
| 68 | 68 | * @param string $className class-name to return builder instance for | 
| 69 | 69 | * @return GenericBuilder builder instance for class | 
| 70 | 70 | */ | 
| 71 | -    public static function getInstance($className){ | |
| 72 | -        if(!array_key_exists((string)$className, self::$instances)) { | |
| 71 | +    public static function getInstance($className) { | |
| 72 | +        if (!array_key_exists((string)$className, self::$instances)) { | |
| 73 | 73 | new GenericBuilder($className); | 
| 74 | 74 | } | 
| 75 | 75 | return self::$instances[$className]; | 
| @@ -82,9 +82,9 @@ discard block | ||
| 82 | 82 | * @param array $arguments array of constructore arguments | 
| 83 | 83 | * @return object the created object instance | 
| 84 | 84 | */ | 
| 85 | -    public function build(array $arguments = array()){       | |
| 86 | -        if(Test::assertClassHasConstructor($this->className)){ | |
| 87 | -            if(!Test::assertRequiredConstructorParameters($this->className, $arguments)){ | |
| 85 | +    public function build(array $arguments = array()) {       | |
| 86 | +        if (Test::assertClassHasConstructor($this->className)) { | |
| 87 | +            if (!Test::assertRequiredConstructorParameters($this->className, $arguments)) { | |
| 88 | 88 |                  throw new \Exception('Missing Argument '.(count($arguments) + 1).' for '.$this->className.'::__construct'); | 
| 89 | 89 | } | 
| 90 | 90 | return $this->getReflectionClass()->newInstanceArgs($arguments); | 
| @@ -98,7 +98,7 @@ discard block | ||
| 98 | 98 | * @access public | 
| 99 | 99 | * @return ReflectionClass | 
| 100 | 100 | */ | 
| 101 | -    public function getReflectionClass(){ | |
| 101 | +    public function getReflectionClass() { | |
| 102 | 102 | return ReflectionPool::getInstance($this->className); | 
| 103 | 103 | } | 
| 104 | 104 | |
| @@ -43,7 +43,7 @@ | ||
| 43 | 43 | class_exists($className); | 
| 44 | 44 | $res = ReflectionPool::getInstance($className) | 
| 45 | 45 | ->implementsInterface($interfaceName); | 
| 46 | -        }  catch (\Exception $e){ | |
| 46 | +        } catch (\Exception $e){ | |
| 47 | 47 | $res = false; | 
| 48 | 48 | } | 
| 49 | 49 | return $res;; | 
| @@ -15,11 +15,11 @@ discard block | ||
| 15 | 15 |  class Test { | 
| 16 | 16 | |
| 17 | 17 | |
| 18 | -    public static function assertClassHasConstructor($className){ | |
| 19 | - return (boolean) ReflectionPool::getInstance($className)->getConstructor(); | |
| 18 | +    public static function assertClassHasConstructor($className) { | |
| 19 | + return (boolean)ReflectionPool::getInstance($className)->getConstructor(); | |
| 20 | 20 | } | 
| 21 | 21 | |
| 22 | -    public static function assertRequiredConstructorParameters($className, $parameters){ | |
| 22 | +    public static function assertRequiredConstructorParameters($className, $parameters) { | |
| 23 | 23 | return (boolean) | 
| 24 | 24 | !self::assertClassHasConstructor($className) || | 
| 25 | 25 | count($parameters) >= ReflectionPool::getInstance($className) | 
| @@ -27,55 +27,55 @@ discard block | ||
| 27 | 27 | ->getNumberOfRequiredParameters(); | 
| 28 | 28 | } | 
| 29 | 29 | |
| 30 | -    public static function assertInstanceOf($className, $object){ | |
| 31 | - return (boolean) ReflectionPool::getInstance($className) | |
| 30 | +    public static function assertInstanceOf($className, $object) { | |
| 31 | + return (boolean)ReflectionPool::getInstance($className) | |
| 32 | 32 | ->isInstance($object); | 
| 33 | 33 | } | 
| 34 | 34 | |
| 35 | -    public static function assertClassOrInterfaceExists($className){ | |
| 36 | - return (boolean) class_exists($className) || interface_exists($className); | |
| 35 | +    public static function assertClassOrInterfaceExists($className) { | |
| 36 | + return (boolean)class_exists($className) || interface_exists($className); | |
| 37 | 37 | } | 
| 38 | 38 | |
| 39 | -    public static function assertImplements($className, $interfaceName){ | |
| 39 | +    public static function assertImplements($className, $interfaceName) { | |
| 40 | 40 | $className = is_object($className) ? get_class($className) : $className; | 
| 41 | - $res = false;//throw new \Exception(); | |
| 41 | + $res = false; //throw new \Exception(); | |
| 42 | 42 |          try {   | 
| 43 | 43 | class_exists($className); | 
| 44 | - $res = ReflectionPool::getInstance($className) | |
| 44 | + $res = ReflectionPool::getInstance($className) | |
| 45 | 45 | ->implementsInterface($interfaceName); | 
| 46 | -        }  catch (\Exception $e){ | |
| 46 | +        } catch (\Exception $e) { | |
| 47 | 47 | $res = false; | 
| 48 | 48 | } | 
| 49 | - return $res;; | |
| 49 | + return $res; ; | |
| 50 | 50 | } | 
| 51 | 51 | |
| 52 | -    public static function assertMessage($message){ | |
| 52 | +    public static function assertMessage($message) { | |
| 53 | 53 | return self::assertImplements($message, '\PEIP\INF\Message\Message'); | 
| 54 | 54 | } | 
| 55 | 55 | |
| 56 | -    public static function assertEvent($event){ | |
| 56 | +    public static function assertEvent($event) { | |
| 57 | 57 | return self::assertImplements($event, '\PEIP\INF\Event\Event'); | 
| 58 | 58 | } | 
| 59 | 59 | |
| 60 | -    public static function assertEventSubject($event){ | |
| 60 | +    public static function assertEventSubject($event) { | |
| 61 | 61 | return self::assertImplements($event, '\PEIP\INF\Event\Event') | 
| 62 | 62 | && $event->getSubject(); | 
| 63 | 63 | } | 
| 64 | 64 | |
| 65 | -    public static function assertEventObjectSubject($event){ | |
| 65 | +    public static function assertEventObjectSubject($event) { | |
| 66 | 66 | return self::assertEventSubject($event) | 
| 67 | 67 | && is_object($event->getSubject()); | 
| 68 | 68 | } | 
| 69 | -    public static function assertArrayAccess($var){ | |
| 70 | - return (boolean) is_array($var) || $var instanceof \ArrayAccess; | |
| 69 | +    public static function assertArrayAccess($var) { | |
| 70 | + return (boolean)is_array($var) || $var instanceof \ArrayAccess; | |
| 71 | 71 | } | 
| 72 | 72 | |
| 73 | -    public static function assertHandler($var){ | |
| 74 | - return (boolean) is_callable($var) || $var instanceof \PEIP\INF\Handler\Handler; | |
| 73 | +    public static function assertHandler($var) { | |
| 74 | + return (boolean)is_callable($var) || $var instanceof \PEIP\INF\Handler\Handler; | |
| 75 | 75 | } | 
| 76 | 76 | |
| 77 | -    public static function castType($var, $type){ | |
| 78 | -        switch($type){ | |
| 77 | +    public static function castType($var, $type) { | |
| 78 | +        switch ($type) { | |
| 79 | 79 | case 'string': | 
| 80 | 80 | $var = (string)$var; | 
| 81 | 81 | break; | 
| @@ -99,8 +99,8 @@ discard block | ||
| 99 | 99 | return $var; | 
| 100 | 100 | } | 
| 101 | 101 | |
| 102 | -    public static function ensureArrayAccess($var){ | |
| 103 | -        if(!Test::assertArrayAccess($var)){ | |
| 102 | +    public static function ensureArrayAccess($var) { | |
| 103 | +        if (!Test::assertArrayAccess($var)) { | |
| 104 | 104 | throw new \InvalidArgumentException( | 
| 105 | 105 | 'Value is not an array nor an instance of ArrayAccess' | 
| 106 | 106 | ); | 
| @@ -109,8 +109,8 @@ discard block | ||
| 109 | 109 | } | 
| 110 | 110 | |
| 111 | 111 | |
| 112 | -    public static function ensureHandler($var){ | |
| 113 | -        if(!Test::assertHandler($var)){ | |
| 112 | +    public static function ensureHandler($var) { | |
| 113 | +        if (!Test::assertHandler($var)) { | |
| 114 | 114 | throw new \InvalidArgumentException( | 
| 115 | 115 | 'Value is not an callable nor an instance of \PEIP\INF\Handler\Handler' | 
| 116 | 116 | ); | 
| @@ -118,8 +118,8 @@ discard block | ||
| 118 | 118 | return $var; | 
| 119 | 119 | } | 
| 120 | 120 | |
| 121 | -    public static function ensureImplements($className, $interfaceName){ | |
| 122 | -        if(!Test::assertImplements($className, $interfaceName)){ | |
| 121 | +    public static function ensureImplements($className, $interfaceName) { | |
| 122 | +        if (!Test::assertImplements($className, $interfaceName)) { | |
| 123 | 123 | throw new \InvalidArgumentException( | 
| 124 | 124 | 'Class "'.$className.'" is not an instanceof "'.$interfaceName.'"' | 
| 125 | 125 | ); | 
| @@ -127,7 +127,7 @@ discard block | ||
| 127 | 127 | return $className; | 
| 128 | 128 | } | 
| 129 | 129 | |
| 130 | -    public static function assertMethod($className, $methodname){ | |
| 130 | +    public static function assertMethod($className, $methodname) { | |
| 131 | 131 | return ReflectionPool::getInstance($className)->hasMethod($methodname); | 
| 132 | 132 | } | 
| 133 | 133 | |
| @@ -37,7 +37,7 @@ discard block | ||
| 37 | 37 | * @param string $eventClass the event-class the builder shall create instances for | 
| 38 | 38 | * @param array $defaultHeaders default headers for the created events | 
| 39 | 39 | */ | 
| 40 | -    public function __construct($eventClass = '\PEIP\Event\Event', array $defaultHeaders = array()){ | |
| 40 | +    public function __construct($eventClass = '\PEIP\Event\Event', array $defaultHeaders = array()) { | |
| 41 | 41 | $this->eventClass = $eventClass; | 
| 42 | 42 | $this->defaultParameters = $defaultHeaders; | 
| 43 | 43 | } | 
| @@ -49,7 +49,7 @@ discard block | ||
| 49 | 49 | * @param string $eventClass the event-class the builder shall create instances for | 
| 50 | 50 | * @return EventBuilder the instance of EventBuilder for the given event-class | 
| 51 | 51 | */ | 
| 52 | -    public static function getInstance($eventClass = '\PEIP\Event\Event'){  | |
| 52 | +    public static function getInstance($eventClass = '\PEIP\Event\Event') {  | |
| 53 | 53 | |
| 54 | 54 | return isset(self::$instances[$eventClass]) | 
| 55 | 55 | ? self::$instances[$eventClass] | 
| @@ -67,7 +67,7 @@ discard block | ||
| 67 | 67 | * @param array $headers the headers for the event | 
| 68 | 68 | * @return object event instance | 
| 69 | 69 | */ | 
| 70 | -    public function build($subject, $name, array $headers = array()){ | |
| 70 | +    public function build($subject, $name, array $headers = array()) { | |
| 71 | 71 | |
| 72 | 72 | return new $this->eventClass( | 
| 73 | 73 | $subject, | 
| @@ -86,7 +86,7 @@ discard block | ||
| 86 | 86 | * @param array $parameters the headers for the event | 
| 87 | 87 | * @return | 
| 88 | 88 | */ | 
| 89 | -    public function buildAndDispatch(ObjectEventDispatcher $dispatcher, $subject, $name, array $headers = array()){ | |
| 89 | +    public function buildAndDispatch(ObjectEventDispatcher $dispatcher, $subject, $name, array $headers = array()) { | |
| 90 | 90 | |
| 91 | 91 | return $dispatcher->notify( | 
| 92 | 92 | $name, |