@@ -25,26 +25,26 @@ |
||
| 25 | 25 | |
| 26 | 26 | interface StoreCollection {
|
| 27 | 27 | |
| 28 | - public function setValues($namespace, array $parameters); |
|
| 28 | + public function setValues($namespace, array $parameters); |
|
| 29 | 29 | |
| 30 | - public function addValues($namespace, array $parameters); |
|
| 30 | + public function addValues($namespace, array $parameters); |
|
| 31 | 31 | |
| 32 | - public function getValues($namespace); |
|
| 32 | + public function getValues($namespace); |
|
| 33 | 33 | |
| 34 | - public function getValue($namespace, $name); |
|
| 34 | + public function getValue($namespace, $name); |
|
| 35 | 35 | |
| 36 | - public function setValue($namespace, $name, $value); |
|
| 36 | + public function setValue($namespace, $name, $value); |
|
| 37 | 37 | |
| 38 | - public function hasValue($namespace, $name); |
|
| 38 | + public function hasValue($namespace, $name); |
|
| 39 | 39 | |
| 40 | - public function deleteValue($namespace, $name); |
|
| 40 | + public function deleteValue($namespace, $name); |
|
| 41 | 41 | |
| 42 | - public function setStore($namespace, \PEIP\INF\Data\Store $store); |
|
| 42 | + public function setStore($namespace, \PEIP\INF\Data\Store $store); |
|
| 43 | 43 | |
| 44 | - public function getStore($namespace); |
|
| 44 | + public function getStore($namespace); |
|
| 45 | 45 | |
| 46 | - public function hasStore($namespace); |
|
| 46 | + public function hasStore($namespace); |
|
| 47 | 47 | |
| 48 | - public function deleteStore($namespace); |
|
| 48 | + public function deleteStore($namespace); |
|
| 49 | 49 | |
| 50 | 50 | } |
| 51 | 51 | \ No newline at end of file |
@@ -33,7 +33,7 @@ discard block |
||
| 33 | 33 | * @param callable $callable the callable to wrap with the handler |
| 34 | 34 | * @return |
| 35 | 35 | */ |
| 36 | - public function __construct($callable){
|
|
| 36 | + public function __construct($callable) {
|
|
| 37 | 37 | $this->callable = $callable; |
| 38 | 38 | } |
| 39 | 39 | |
@@ -45,7 +45,7 @@ discard block |
||
| 45 | 45 | * @param mixed $subject the subject to handle |
| 46 | 46 | * @return mixed result of calling the registered callable with given subject |
| 47 | 47 | */ |
| 48 | - public function handle($subject){
|
|
| 48 | + public function handle($subject) {
|
|
| 49 | 49 | return call_user_func($this->callable, $subject); |
| 50 | 50 | } |
| 51 | 51 | |
@@ -58,7 +58,7 @@ discard block |
||
| 58 | 58 | * @return mixed result of calling the registered callable with given subject |
| 59 | 59 | * @see CallableHandler::handle |
| 60 | 60 | */ |
| 61 | - public function __invoke($subject){
|
|
| 61 | + public function __invoke($subject) {
|
|
| 62 | 62 | return $this->handle($subject); |
| 63 | 63 | } |
| 64 | 64 | |
@@ -68,7 +68,7 @@ discard block |
||
| 68 | 68 | * @access public |
| 69 | 69 | * @return callable callable wrapped by the handler |
| 70 | 70 | */ |
| 71 | - public function getCallable(){
|
|
| 71 | + public function getCallable() {
|
|
| 72 | 72 | return $this->callable; |
| 73 | 73 | } |
| 74 | 74 | |
@@ -33,7 +33,7 @@ discard block |
||
| 33 | 33 | * @param $className |
| 34 | 34 | * @return |
| 35 | 35 | */ |
| 36 | - public function __construct($className){
|
|
| 36 | + public function __construct($className) {
|
|
| 37 | 37 | $this->className = $className; |
| 38 | 38 | } |
| 39 | 39 | |
@@ -43,7 +43,7 @@ discard block |
||
| 43 | 43 | * @param $message |
| 44 | 44 | * @return |
| 45 | 45 | */ |
| 46 | - public function acceptMessage(\PEIP\INF\Message\Message $message){
|
|
| 46 | + public function acceptMessage(\PEIP\INF\Message\Message $message) {
|
|
| 47 | 47 | return $message->getContent() instanceof $className; |
| 48 | 48 | } |
| 49 | 49 | |
@@ -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 | |
@@ -39,7 +39,7 @@ |
||
| 39 | 39 | * |
| 40 | 40 | * @access public |
| 41 | 41 | * @param string $className class-name to create objects for |
| 42 | - * @param ReflectionClass $reflectionClass reflection-class for class. default: NULL |
|
| 42 | + * @param \ReflectionClass $reflectionClass reflection-class for class. default: NULL |
|
| 43 | 43 | * @param boolean $storeRef wether to store a reference for new instance. default: true |
| 44 | 44 | * @return |
| 45 | 45 | */ |
@@ -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 |
@@ -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 | |
@@ -83,7 +83,6 @@ |
||
| 83 | 83 | * @param ObjectEventDispatcher $dispatcher the dispatcher to dispatch the event |
| 84 | 84 | * @param mixed $subject the subject for the event |
| 85 | 85 | * @param string $name the name of the event |
| 86 | - * @param array $parameters the headers for the event |
|
| 87 | 86 | * @return |
| 88 | 87 | */ |
| 89 | 88 | public function buildAndDispatch(ObjectEventDispatcher $dispatcher, $subject, $name, array $headers = array()){
|
@@ -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, |
@@ -33,7 +33,7 @@ discard block |
||
| 33 | 33 | * @param $discardChannel |
| 34 | 34 | * @return |
| 35 | 35 | */ |
| 36 | - public function setDiscardChannel(\PEIP\INF\Channel\Channel $discardChannel){
|
|
| 36 | + public function setDiscardChannel(\PEIP\INF\Channel\Channel $discardChannel) {
|
|
| 37 | 37 | $this->discardChannel = $discardChannel; |
| 38 | 38 | } |
| 39 | 39 | |
@@ -42,7 +42,7 @@ discard block |
||
| 42 | 42 | * @access public |
| 43 | 43 | * @return |
| 44 | 44 | */ |
| 45 | - public function getDiscardChannel(){
|
|
| 45 | + public function getDiscardChannel() {
|
|
| 46 | 46 | return $this->discardChannel; |
| 47 | 47 | } |
| 48 | 48 | |
@@ -52,8 +52,8 @@ discard block |
||
| 52 | 52 | * @param $message |
| 53 | 53 | * @return |
| 54 | 54 | */ |
| 55 | - protected function discardMessage(\PEIP\INF\Message\Message $message){
|
|
| 56 | - if(isset($this->discardChannel)){
|
|
| 55 | + protected function discardMessage(\PEIP\INF\Message\Message $message) {
|
|
| 56 | + if (isset($this->discardChannel)) {
|
|
| 57 | 57 | $this->discardChannel->send($message); |
| 58 | 58 | } |
| 59 | 59 | } |
@@ -38,12 +38,12 @@ discard block |
||
| 38 | 38 | * @param \PEIP\INF\Message\Message $message message to handle/reply for |
| 39 | 39 | * @return |
| 40 | 40 | */ |
| 41 | - public function doReply(\PEIP\INF\Message\Message $message){
|
|
| 41 | + public function doReply(\PEIP\INF\Message\Message $message) {
|
|
| 42 | 42 | $res = $this->callService($message); |
| 43 | 43 | $out = (bool)$message->hasHeader('REPLY_CHANNEL')
|
| 44 | 44 | ? $message->getHeader('REPLY_CHANNEL')
|
| 45 | 45 | : $this->outputChannel; |
| 46 | - if($out){
|
|
| 46 | + if ($out) {
|
|
| 47 | 47 | $this->replyMessage($res, $res); |
| 48 | 48 | } |
| 49 | 49 | } |
@@ -56,12 +56,12 @@ discard block |
||
| 56 | 56 | * @param \PEIP\INF\Message\Message $message message to call the service with it�s content/payload |
| 57 | 57 | * @return mixed result of calling the registered service callable with message content/payload |
| 58 | 58 | */ |
| 59 | - protected function callService(\PEIP\INF\Message\Message $message){
|
|
| 59 | + protected function callService(\PEIP\INF\Message\Message $message) {
|
|
| 60 | 60 | $res = NULL; |
| 61 | - if(is_callable($this->serviceCallable)){
|
|
| 61 | + if (is_callable($this->serviceCallable)) {
|
|
| 62 | 62 | $res = call_user_func($this->serviceCallable, $message->getContent()); |
| 63 | - }else{
|
|
| 64 | - if(is_object($this->serviceCallable) && method_exists($this->serviceCallable, 'handle')){
|
|
| 63 | + }else {
|
|
| 64 | + if (is_object($this->serviceCallable) && method_exists($this->serviceCallable, 'handle')) {
|
|
| 65 | 65 | $res = $this->serviceCallable->handle($message->getContent()); |
| 66 | 66 | } |
| 67 | 67 | } |
@@ -17,7 +17,7 @@ |
||
| 17 | 17 | protected function getMessage($object){
|
| 18 | 18 | if($this->channel instanceof \PEIP\INF\Channel\SubscribableChannel){
|
| 19 | 19 | return $object; |
| 20 | - }else{
|
|
| 20 | + } else{
|
|
| 21 | 21 | return $object->getContent()->receive(); |
| 22 | 22 | } |
| 23 | 23 | } |
@@ -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 | |
@@ -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;; |