@@ -10,29 +10,29 @@ |
||
| 10 | 10 | |
| 11 | 11 | protected function setUp() |
| 12 | 12 | { |
| 13 | - if( class_exists( '\PhpAmqpLib\Message\AMQPMessage' ) === false ) { |
|
| 14 | - $this->markTestSkipped( 'Please install the "php-amqplib" library via composer first' ); |
|
| 13 | + if (class_exists('\PhpAmqpLib\Message\AMQPMessage') === false) { |
|
| 14 | + $this->markTestSkipped('Please install the "php-amqplib" library via composer first'); |
|
| 15 | 15 | } |
| 16 | 16 | |
| 17 | - $msg = new \PhpAmqpLib\Message\AMQPMessage( 'test' ); |
|
| 18 | - $this->object = new \Aimeos\MW\MQueue\Message\AMQP( $msg ); |
|
| 17 | + $msg = new \PhpAmqpLib\Message\AMQPMessage('test'); |
|
| 18 | + $this->object = new \Aimeos\MW\MQueue\Message\AMQP($msg); |
|
| 19 | 19 | } |
| 20 | 20 | |
| 21 | 21 | |
| 22 | 22 | protected function tearDown() |
| 23 | 23 | { |
| 24 | - unset( $this->object ); |
|
| 24 | + unset($this->object); |
|
| 25 | 25 | } |
| 26 | 26 | |
| 27 | 27 | |
| 28 | 28 | public function testGetBody() |
| 29 | 29 | { |
| 30 | - $this->assertEquals( 'test', $this->object->getBody() ); |
|
| 30 | + $this->assertEquals('test', $this->object->getBody()); |
|
| 31 | 31 | } |
| 32 | 32 | |
| 33 | 33 | |
| 34 | 34 | public function testGetObject() |
| 35 | 35 | { |
| 36 | - $this->assertInstanceOf( '\PhpAmqpLib\Message\AMQPMessage', $this->object->getObject() ); |
|
| 36 | + $this->assertInstanceOf('\PhpAmqpLib\Message\AMQPMessage', $this->object->getObject()); |
|
| 37 | 37 | } |
| 38 | 38 | } |
@@ -7,8 +7,8 @@ discard block |
||
| 7 | 7 | { |
| 8 | 8 | protected function setUp() |
| 9 | 9 | { |
| 10 | - if( class_exists( '\PhpAmqpLib\Connection\AMQPStreamConnection' ) === false ) { |
|
| 11 | - $this->markTestSkipped( 'Please install the "php-amqplib" library via composer first' ); |
|
| 10 | + if (class_exists('\PhpAmqpLib\Connection\AMQPStreamConnection') === false) { |
|
| 11 | + $this->markTestSkipped('Please install the "php-amqplib" library via composer first'); |
|
| 12 | 12 | } |
| 13 | 13 | } |
| 14 | 14 | |
@@ -17,65 +17,65 @@ discard block |
||
| 17 | 17 | { |
| 18 | 18 | try |
| 19 | 19 | { |
| 20 | - $mqueue = new \Aimeos\MW\MQueue\AMQP( array( 'host' => 'localhost' ) ); |
|
| 21 | - $queue = $mqueue->getQueue( 'aimeos_unittest' ); |
|
| 20 | + $mqueue = new \Aimeos\MW\MQueue\AMQP(array('host' => 'localhost')); |
|
| 21 | + $queue = $mqueue->getQueue('aimeos_unittest'); |
|
| 22 | 22 | } |
| 23 | - catch( \Aimeos\MW\MQueue\Exception $e ) |
|
| 23 | + catch (\Aimeos\MW\MQueue\Exception $e) |
|
| 24 | 24 | { |
| 25 | - $this->markTestSkipped( 'No AMQP compliant server available at "localhost"' ); |
|
| 25 | + $this->markTestSkipped('No AMQP compliant server available at "localhost"'); |
|
| 26 | 26 | } |
| 27 | 27 | |
| 28 | - $queue->add( 'testmsg' ); |
|
| 28 | + $queue->add('testmsg'); |
|
| 29 | 29 | $msg = $queue->get(); |
| 30 | - $queue->del( $msg ); |
|
| 30 | + $queue->del($msg); |
|
| 31 | 31 | |
| 32 | - $this->assertNull( $queue->get() ); |
|
| 32 | + $this->assertNull($queue->get()); |
|
| 33 | 33 | } |
| 34 | 34 | |
| 35 | 35 | |
| 36 | 36 | public function testSingleConnection() |
| 37 | 37 | { |
| 38 | - $this->setExpectedException( '\Aimeos\MW\MQueue\Exception' ); |
|
| 39 | - new \Aimeos\MW\MQueue\AMQP( array( 'host' => '192.168.255.255', 'connection_timeout' => 0.1 ) ); |
|
| 38 | + $this->setExpectedException('\Aimeos\MW\MQueue\Exception'); |
|
| 39 | + new \Aimeos\MW\MQueue\AMQP(array('host' => '192.168.255.255', 'connection_timeout' => 0.1)); |
|
| 40 | 40 | } |
| 41 | 41 | |
| 42 | 42 | |
| 43 | 43 | public function testMultiConnection() |
| 44 | 44 | { |
| 45 | - $this->setExpectedException( '\Aimeos\MW\MQueue\Exception' ); |
|
| 46 | - new \Aimeos\MW\MQueue\AMQP( array( 'host' => array( '192.168.254.255', '192.168.255.255' ), 'connection_timeout' => 0.1 ) ); |
|
| 45 | + $this->setExpectedException('\Aimeos\MW\MQueue\Exception'); |
|
| 46 | + new \Aimeos\MW\MQueue\AMQP(array('host' => array('192.168.254.255', '192.168.255.255'), 'connection_timeout' => 0.1)); |
|
| 47 | 47 | } |
| 48 | 48 | |
| 49 | 49 | |
| 50 | 50 | public function testGetQueue() |
| 51 | 51 | { |
| 52 | - $channel = $this->getMockBuilder( 'PhpAmqpLib\Channel\AMQPChannel' ) |
|
| 52 | + $channel = $this->getMockBuilder('PhpAmqpLib\Channel\AMQPChannel') |
|
| 53 | 53 | ->disableOriginalConstructor() |
| 54 | 54 | ->getMock(); |
| 55 | 55 | |
| 56 | - $object = $this->getMockBuilder( '\Aimeos\MW\MQueue\AMQP' ) |
|
| 57 | - ->setMethods( array( 'getChannel', '__destruct' ) ) |
|
| 56 | + $object = $this->getMockBuilder('\Aimeos\MW\MQueue\AMQP') |
|
| 57 | + ->setMethods(array('getChannel', '__destruct')) |
|
| 58 | 58 | ->disableOriginalConstructor() |
| 59 | 59 | ->getMock(); |
| 60 | 60 | |
| 61 | - $object->expects( $this->once() )->method( 'getChannel' ) |
|
| 62 | - ->will( $this->returnValue( $channel ) ); |
|
| 61 | + $object->expects($this->once())->method('getChannel') |
|
| 62 | + ->will($this->returnValue($channel)); |
|
| 63 | 63 | |
| 64 | - $this->assertInstanceOf( '\Aimeos\MW\MQueue\Queue\Iface', $object->getQueue( 'test' ) ); |
|
| 64 | + $this->assertInstanceOf('\Aimeos\MW\MQueue\Queue\Iface', $object->getQueue('test')); |
|
| 65 | 65 | } |
| 66 | 66 | |
| 67 | 67 | |
| 68 | 68 | public function testGetQueueException() |
| 69 | 69 | { |
| 70 | - $object = $this->getMockBuilder( '\Aimeos\MW\MQueue\AMQP' ) |
|
| 71 | - ->setMethods( array( 'getChannel', '__destruct' ) ) |
|
| 70 | + $object = $this->getMockBuilder('\Aimeos\MW\MQueue\AMQP') |
|
| 71 | + ->setMethods(array('getChannel', '__destruct')) |
|
| 72 | 72 | ->disableOriginalConstructor() |
| 73 | 73 | ->getMock(); |
| 74 | 74 | |
| 75 | - $object->expects( $this->once() )->method( 'getChannel' ) |
|
| 76 | - ->will( $this->throwException( new \Exception() ) ); |
|
| 75 | + $object->expects($this->once())->method('getChannel') |
|
| 76 | + ->will($this->throwException(new \Exception())); |
|
| 77 | 77 | |
| 78 | - $this->setExpectedException( '\Aimeos\MW\MQueue\Exception' ); |
|
| 79 | - $object->getQueue( 'test' ); |
|
| 78 | + $this->setExpectedException('\Aimeos\MW\MQueue\Exception'); |
|
| 79 | + $object->getQueue('test'); |
|
| 80 | 80 | } |
| 81 | 81 | } |
@@ -19,8 +19,7 @@ |
||
| 19 | 19 | { |
| 20 | 20 | $mqueue = new \Aimeos\MW\MQueue\AMQP( array( 'host' => 'localhost' ) ); |
| 21 | 21 | $queue = $mqueue->getQueue( 'aimeos_unittest' ); |
| 22 | - } |
|
| 23 | - catch( \Aimeos\MW\MQueue\Exception $e ) |
|
| 22 | + } catch( \Aimeos\MW\MQueue\Exception $e ) |
|
| 24 | 23 | { |
| 25 | 24 | $this->markTestSkipped( 'No AMQP compliant server available at "localhost"' ); |
| 26 | 25 | } |
@@ -14,38 +14,38 @@ discard block |
||
| 14 | 14 | * @param string $name Queue name |
| 15 | 15 | * @return \Aimeos\MW\MQueue\Queue\Iface Message queue |
| 16 | 16 | */ |
| 17 | - public function getQueue( $name ) |
|
| 17 | + public function getQueue($name) |
|
| 18 | 18 | { |
| 19 | - if( !isset( $this->queues[$name] ) ) |
|
| 19 | + if (!isset($this->queues[$name])) |
|
| 20 | 20 | { |
| 21 | - $uri = $this->getConfig( 'uri', 'tcp://localhost:61613' ); |
|
| 22 | - $user = $this->getConfig( 'username', null ); |
|
| 23 | - $pass = $this->getConfig( 'password', null ); |
|
| 21 | + $uri = $this->getConfig('uri', 'tcp://localhost:61613'); |
|
| 22 | + $user = $this->getConfig('username', null); |
|
| 23 | + $pass = $this->getConfig('password', null); |
|
| 24 | 24 | |
| 25 | - if( is_array( $uri ) ) |
|
| 25 | + if (is_array($uri)) |
|
| 26 | 26 | { |
| 27 | - foreach( $uri as $idx => $entry ) |
|
| 27 | + foreach ($uri as $idx => $entry) |
|
| 28 | 28 | { |
| 29 | - $iuser = ( is_array( $user) ? $user[$idx] : $user ); |
|
| 30 | - $ipass = ( is_array( $pass) ? $pass[$idx] : $pass ); |
|
| 29 | + $iuser = (is_array($user) ? $user[$idx] : $user); |
|
| 30 | + $ipass = (is_array($pass) ? $pass[$idx] : $pass); |
|
| 31 | 31 | |
| 32 | - $result = $this->connect( $entry, $iuser, $ipass ); |
|
| 32 | + $result = $this->connect($entry, $iuser, $ipass); |
|
| 33 | 33 | |
| 34 | - if( $result instanceof \Stomp ) { |
|
| 34 | + if ($result instanceof \Stomp) { |
|
| 35 | 35 | break; |
| 36 | 36 | } |
| 37 | 37 | } |
| 38 | 38 | } |
| 39 | 39 | else |
| 40 | 40 | { |
| 41 | - $result = $this->connect( $uri, $user, $pass ); |
|
| 41 | + $result = $this->connect($uri, $user, $pass); |
|
| 42 | 42 | } |
| 43 | 43 | |
| 44 | - if( $result instanceof \StompException ) { |
|
| 45 | - throw new \Aimeos\MW\MQueue\Exception( $result->getMessage() ); |
|
| 44 | + if ($result instanceof \StompException) { |
|
| 45 | + throw new \Aimeos\MW\MQueue\Exception($result->getMessage()); |
|
| 46 | 46 | } |
| 47 | 47 | |
| 48 | - $this->queues[$name] = new \Aimeos\MW\MQueue\Queue\Stomp( $result, $name ); |
|
| 48 | + $this->queues[$name] = new \Aimeos\MW\MQueue\Queue\Stomp($result, $name); |
|
| 49 | 49 | } |
| 50 | 50 | |
| 51 | 51 | return $this->queues[$name]; |
@@ -60,11 +60,11 @@ discard block |
||
| 60 | 60 | * @param string $pass Password for authentication |
| 61 | 61 | * @return \Stomp|\StompException |
| 62 | 62 | */ |
| 63 | - protected function connect( $uri, $user, $pass ) |
|
| 63 | + protected function connect($uri, $user, $pass) |
|
| 64 | 64 | { |
| 65 | 65 | try { |
| 66 | - return new \Stomp( $uri, $user, $pass ); |
|
| 67 | - } catch( \StompException $e ) { |
|
| 66 | + return new \Stomp($uri, $user, $pass); |
|
| 67 | + } catch (\StompException $e) { |
|
| 68 | 68 | return $e; |
| 69 | 69 | } |
| 70 | 70 | } |
@@ -35,8 +35,7 @@ |
||
| 35 | 35 | break; |
| 36 | 36 | } |
| 37 | 37 | } |
| 38 | - } |
|
| 39 | - else |
|
| 38 | + } else |
|
| 40 | 39 | { |
| 41 | 40 | $result = $this->connect( $uri, $user, $pass ); |
| 42 | 41 | } |
@@ -17,12 +17,12 @@ discard block |
||
| 17 | 17 | * @param string $queue Message queue name |
| 18 | 18 | * @throws \Aimeos\MW\MQueue\Exception |
| 19 | 19 | */ |
| 20 | - public function __construct( \Pheanstalk\PheanstalkInterface $client, $queue, $timeout = null ) |
|
| 20 | + public function __construct(\Pheanstalk\PheanstalkInterface $client, $queue, $timeout = null) |
|
| 21 | 21 | { |
| 22 | 22 | try { |
| 23 | - $client->useTube( $queue )->watch( $queue ); |
|
| 24 | - } catch( \Exception $e ) { |
|
| 25 | - throw new \Aimeos\MW\MQueue\Exception( $e->getMessage() ); |
|
| 23 | + $client->useTube($queue)->watch($queue); |
|
| 24 | + } catch (\Exception $e) { |
|
| 25 | + throw new \Aimeos\MW\MQueue\Exception($e->getMessage()); |
|
| 26 | 26 | } |
| 27 | 27 | |
| 28 | 28 | $this->client = $client; |
@@ -36,12 +36,12 @@ discard block |
||
| 36 | 36 | * |
| 37 | 37 | * @param string $msg Message, e.g. JSON encoded data |
| 38 | 38 | */ |
| 39 | - public function add( $msg ) |
|
| 39 | + public function add($msg) |
|
| 40 | 40 | { |
| 41 | 41 | try { |
| 42 | - $this->client->put( $msg ); |
|
| 43 | - } catch( \Exception $e ) { |
|
| 44 | - throw new \Aimeos\MW\MQueue\Exception( $e->getMessage() ); |
|
| 42 | + $this->client->put($msg); |
|
| 43 | + } catch (\Exception $e) { |
|
| 44 | + throw new \Aimeos\MW\MQueue\Exception($e->getMessage()); |
|
| 45 | 45 | } |
| 46 | 46 | } |
| 47 | 47 | |
@@ -51,12 +51,12 @@ discard block |
||
| 51 | 51 | * |
| 52 | 52 | * @param \Aimeos\MW\MQueue\Message\Iface $msg Message object |
| 53 | 53 | */ |
| 54 | - public function del( \Aimeos\MW\MQueue\Message\Iface $msg ) |
|
| 54 | + public function del(\Aimeos\MW\MQueue\Message\Iface $msg) |
|
| 55 | 55 | { |
| 56 | 56 | try { |
| 57 | - $this->client->delete( $msg->getObject() ); |
|
| 58 | - } catch( \Exception $e ) { |
|
| 59 | - throw new \Aimeos\MW\MQueue\Exception( $e->getMessage() ); |
|
| 57 | + $this->client->delete($msg->getObject()); |
|
| 58 | + } catch (\Exception $e) { |
|
| 59 | + throw new \Aimeos\MW\MQueue\Exception($e->getMessage()); |
|
| 60 | 60 | } |
| 61 | 61 | } |
| 62 | 62 | |
@@ -68,8 +68,8 @@ discard block |
||
| 68 | 68 | */ |
| 69 | 69 | public function get() |
| 70 | 70 | { |
| 71 | - if( ( $job = $this->client->reserve( $this->timeout ) ) !== false ) { |
|
| 72 | - return new \Aimeos\MW\MQueue\Message\Beanstalk( $job ); |
|
| 71 | + if (($job = $this->client->reserve($this->timeout)) !== false) { |
|
| 72 | + return new \Aimeos\MW\MQueue\Message\Beanstalk($job); |
|
| 73 | 73 | } |
| 74 | 74 | } |
| 75 | 75 | } |
@@ -14,32 +14,32 @@ discard block |
||
| 14 | 14 | * |
| 15 | 15 | * @param array $config Associative list of configuration key/value pairs |
| 16 | 16 | */ |
| 17 | - public function __construct( array $config ) |
|
| 17 | + public function __construct(array $config) |
|
| 18 | 18 | { |
| 19 | - parent::__construct( $config ); |
|
| 19 | + parent::__construct($config); |
|
| 20 | 20 | |
| 21 | - $host = $this->getConfig( 'host', 'localhost' ); |
|
| 22 | - $port = $this->getConfig( 'port', \Pheanstalk\PheanstalkInterface::DEFAULT_PORT ); |
|
| 21 | + $host = $this->getConfig('host', 'localhost'); |
|
| 22 | + $port = $this->getConfig('port', \Pheanstalk\PheanstalkInterface::DEFAULT_PORT); |
|
| 23 | 23 | |
| 24 | - if( is_array( $host ) ) |
|
| 24 | + if (is_array($host)) |
|
| 25 | 25 | { |
| 26 | - foreach( $host as $idx => $entry ) |
|
| 26 | + foreach ($host as $idx => $entry) |
|
| 27 | 27 | { |
| 28 | - $iport = ( is_array( $port) ? $port[$idx] : $port ); |
|
| 29 | - $this->client = $this->connect( $entry, $iport ); |
|
| 28 | + $iport = (is_array($port) ? $port[$idx] : $port); |
|
| 29 | + $this->client = $this->connect($entry, $iport); |
|
| 30 | 30 | |
| 31 | - if( $this->client instanceof \Pheanstalk\PheanstalkInterface ) { |
|
| 31 | + if ($this->client instanceof \Pheanstalk\PheanstalkInterface) { |
|
| 32 | 32 | break; |
| 33 | 33 | } |
| 34 | 34 | } |
| 35 | 35 | } |
| 36 | 36 | else |
| 37 | 37 | { |
| 38 | - $this->client = $this->connect( $host, $port ); |
|
| 38 | + $this->client = $this->connect($host, $port); |
|
| 39 | 39 | } |
| 40 | 40 | |
| 41 | - if( $this->client instanceof \Pheanstalk\Exception ) { |
|
| 42 | - throw new \Aimeos\MW\MQueue\Exception( $this->client->getMessage() ); |
|
| 41 | + if ($this->client instanceof \Pheanstalk\Exception) { |
|
| 42 | + throw new \Aimeos\MW\MQueue\Exception($this->client->getMessage()); |
|
| 43 | 43 | } |
| 44 | 44 | } |
| 45 | 45 | |
@@ -50,12 +50,12 @@ discard block |
||
| 50 | 50 | * @param string $name Queue name |
| 51 | 51 | * @return \Aimeos\MW\MQueue\Queue\Iface Message queue |
| 52 | 52 | */ |
| 53 | - public function getQueue( $name ) |
|
| 53 | + public function getQueue($name) |
|
| 54 | 54 | { |
| 55 | - if( !isset( $this->queues[$name] ) ) |
|
| 55 | + if (!isset($this->queues[$name])) |
|
| 56 | 56 | { |
| 57 | - $timeout = $this->getConfig( 'readtimeout', 30 ); |
|
| 58 | - $this->queues[$name] = new \Aimeos\MW\MQueue\Queue\Beanstalk( $this->client, $name, $timeout ); |
|
| 57 | + $timeout = $this->getConfig('readtimeout', 30); |
|
| 58 | + $this->queues[$name] = new \Aimeos\MW\MQueue\Queue\Beanstalk($this->client, $name, $timeout); |
|
| 59 | 59 | } |
| 60 | 60 | |
| 61 | 61 | return $this->queues[$name]; |
@@ -69,11 +69,11 @@ discard block |
||
| 69 | 69 | * @param integer $port Port the server is listening |
| 70 | 70 | * @return \Pheanstalk\PheanstalkInterface|\Pheanstalk\Exception |
| 71 | 71 | */ |
| 72 | - protected function connect( $host, $port ) |
|
| 72 | + protected function connect($host, $port) |
|
| 73 | 73 | { |
| 74 | - $conntimeout = $this->getConfig( 'conntimeout', 3 ); |
|
| 75 | - $persist = $this->getConfig( 'persist', false ); |
|
| 74 | + $conntimeout = $this->getConfig('conntimeout', 3); |
|
| 75 | + $persist = $this->getConfig('persist', false); |
|
| 76 | 76 | |
| 77 | - return new \Pheanstalk\Pheanstalk( $host, $port, $conntimeout, $persist ); |
|
| 77 | + return new \Pheanstalk\Pheanstalk($host, $port, $conntimeout, $persist); |
|
| 78 | 78 | } |
| 79 | 79 | } |
| 80 | 80 | \ No newline at end of file |
@@ -32,8 +32,7 @@ |
||
| 32 | 32 | break; |
| 33 | 33 | } |
| 34 | 34 | } |
| 35 | - } |
|
| 36 | - else |
|
| 35 | + } else |
|
| 37 | 36 | { |
| 38 | 37 | $this->client = $this->connect( $host, $port ); |
| 39 | 38 | } |
@@ -13,7 +13,7 @@ |
||
| 13 | 13 | * |
| 14 | 14 | * @param \StompFrame $msg Stomp frame object |
| 15 | 15 | */ |
| 16 | - public function __construct( \StompFrame $msg ) |
|
| 16 | + public function __construct(\StompFrame $msg) |
|
| 17 | 17 | { |
| 18 | 18 | $this->msg = $msg; |
| 19 | 19 | } |
@@ -13,7 +13,7 @@ |
||
| 13 | 13 | * |
| 14 | 14 | * @param \Pheanstalk\Job $job Job object |
| 15 | 15 | */ |
| 16 | - public function __construct( \Pheanstalk\Job $job ) |
|
| 16 | + public function __construct(\Pheanstalk\Job $job) |
|
| 17 | 17 | { |
| 18 | 18 | $this->job = $job; |
| 19 | 19 | } |
@@ -13,7 +13,7 @@ |
||
| 13 | 13 | * |
| 14 | 14 | * @param \PhpAmqpLib\Message\AMQPMessage $msg AMQPMessage object |
| 15 | 15 | */ |
| 16 | - public function __construct( \PhpAmqpLib\Message\AMQPMessage $msg ) |
|
| 16 | + public function __construct(\PhpAmqpLib\Message\AMQPMessage $msg) |
|
| 17 | 17 | { |
| 18 | 18 | $this->msg = $msg; |
| 19 | 19 | } |
@@ -14,37 +14,37 @@ discard block |
||
| 14 | 14 | * |
| 15 | 15 | * @param array $config Associative list of configuration key/value pairs |
| 16 | 16 | */ |
| 17 | - public function __construct( array $config ) |
|
| 17 | + public function __construct(array $config) |
|
| 18 | 18 | { |
| 19 | - parent::__construct( $config ); |
|
| 19 | + parent::__construct($config); |
|
| 20 | 20 | |
| 21 | - $host = $this->getConfig( 'host', 'localhost' ); |
|
| 22 | - $port = $this->getConfig( 'port', 5672 ); |
|
| 23 | - $user = $this->getConfig( 'username', 'guest' ); |
|
| 24 | - $pass = $this->getConfig( 'password', 'guest' ); |
|
| 21 | + $host = $this->getConfig('host', 'localhost'); |
|
| 22 | + $port = $this->getConfig('port', 5672); |
|
| 23 | + $user = $this->getConfig('username', 'guest'); |
|
| 24 | + $pass = $this->getConfig('password', 'guest'); |
|
| 25 | 25 | |
| 26 | - if( is_array( $host ) ) |
|
| 26 | + if (is_array($host)) |
|
| 27 | 27 | { |
| 28 | - foreach( $host as $idx => $entry ) |
|
| 28 | + foreach ($host as $idx => $entry) |
|
| 29 | 29 | { |
| 30 | - $iport = ( is_array( $port) ? $port[$idx] : $port ); |
|
| 31 | - $iuser = ( is_array( $user) ? $user[$idx] : $user ); |
|
| 32 | - $ipass = ( is_array( $pass) ? $pass[$idx] : $pass ); |
|
| 30 | + $iport = (is_array($port) ? $port[$idx] : $port); |
|
| 31 | + $iuser = (is_array($user) ? $user[$idx] : $user); |
|
| 32 | + $ipass = (is_array($pass) ? $pass[$idx] : $pass); |
|
| 33 | 33 | |
| 34 | - $this->conn = $this->connect( $entry, $iport, $iuser, $ipass ); |
|
| 34 | + $this->conn = $this->connect($entry, $iport, $iuser, $ipass); |
|
| 35 | 35 | |
| 36 | - if( $this->conn instanceof \PhpAmqpLib\Connection\AMQPStreamConnection ) { |
|
| 36 | + if ($this->conn instanceof \PhpAmqpLib\Connection\AMQPStreamConnection) { |
|
| 37 | 37 | break; |
| 38 | 38 | } |
| 39 | 39 | } |
| 40 | 40 | } |
| 41 | 41 | else |
| 42 | 42 | { |
| 43 | - $this->conn = $this->connect( $host, $port, $user, $pass ); |
|
| 43 | + $this->conn = $this->connect($host, $port, $user, $pass); |
|
| 44 | 44 | } |
| 45 | 45 | |
| 46 | - if( $this->conn instanceof \Exception ) { |
|
| 47 | - throw new \Aimeos\MW\MQueue\Exception( $this->conn->getMessage() ); |
|
| 46 | + if ($this->conn instanceof \Exception) { |
|
| 47 | + throw new \Aimeos\MW\MQueue\Exception($this->conn->getMessage()); |
|
| 48 | 48 | } |
| 49 | 49 | } |
| 50 | 50 | |
@@ -64,19 +64,19 @@ discard block |
||
| 64 | 64 | * @param string $name Queue name |
| 65 | 65 | * @return \Aimeos\MW\MQueue\Queue\Iface Message queue |
| 66 | 66 | */ |
| 67 | - public function getQueue( $name ) |
|
| 67 | + public function getQueue($name) |
|
| 68 | 68 | { |
| 69 | 69 | try |
| 70 | 70 | { |
| 71 | - if( !isset( $this->queues[$name] ) ) { |
|
| 72 | - $this->queues[$name] = new \Aimeos\MW\MQueue\Queue\AMQP( $this->getChannel(), $name ); |
|
| 71 | + if (!isset($this->queues[$name])) { |
|
| 72 | + $this->queues[$name] = new \Aimeos\MW\MQueue\Queue\AMQP($this->getChannel(), $name); |
|
| 73 | 73 | } |
| 74 | 74 | |
| 75 | 75 | return $this->queues[$name]; |
| 76 | 76 | } |
| 77 | - catch( \Exception $e ) |
|
| 77 | + catch (\Exception $e) |
|
| 78 | 78 | { |
| 79 | - throw new \Aimeos\MW\MQueue\Exception( $e->getMessage() ); |
|
| 79 | + throw new \Aimeos\MW\MQueue\Exception($e->getMessage()); |
|
| 80 | 80 | } |
| 81 | 81 | } |
| 82 | 82 | |
@@ -90,17 +90,17 @@ discard block |
||
| 90 | 90 | * @param string $pass Password for authentication |
| 91 | 91 | * @return \PhpAmqpLib\Connection\AMQPStreamConnection|\PhpAmqpLib\Exception\AMQPException |
| 92 | 92 | */ |
| 93 | - protected function connect( $host, $port, $user, $pass ) |
|
| 93 | + protected function connect($host, $port, $user, $pass) |
|
| 94 | 94 | { |
| 95 | - $vhost = $this->getConfig( 'vhost', '/' ); |
|
| 96 | - $insist = $this->getConfig( 'insist', false ); |
|
| 97 | - $loginMethod = $this->getConfig( 'login_method', 'AMQPLAIN' ); |
|
| 98 | - $loginResponse = $this->getConfig( 'login_response', null ); |
|
| 99 | - $locale = $this->getConfig( 'locale', 'en_US' ); |
|
| 100 | - $conntimeout = $this->getConfig( 'connection_timeout', 3.0 ); |
|
| 101 | - $timeout = $this->getConfig( 'read_write_timeout', 3.0 ); |
|
| 102 | - $keepalive = $this->getConfig( 'keepalive', false ); |
|
| 103 | - $heartbeat = $this->getConfig( 'heartbeat', 0 ); |
|
| 95 | + $vhost = $this->getConfig('vhost', '/'); |
|
| 96 | + $insist = $this->getConfig('insist', false); |
|
| 97 | + $loginMethod = $this->getConfig('login_method', 'AMQPLAIN'); |
|
| 98 | + $loginResponse = $this->getConfig('login_response', null); |
|
| 99 | + $locale = $this->getConfig('locale', 'en_US'); |
|
| 100 | + $conntimeout = $this->getConfig('connection_timeout', 3.0); |
|
| 101 | + $timeout = $this->getConfig('read_write_timeout', 3.0); |
|
| 102 | + $keepalive = $this->getConfig('keepalive', false); |
|
| 103 | + $heartbeat = $this->getConfig('heartbeat', 0); |
|
| 104 | 104 | |
| 105 | 105 | try |
| 106 | 106 | { |
@@ -111,7 +111,7 @@ discard block |
||
| 111 | 111 | $keepalive, $heartbeat |
| 112 | 112 | ); |
| 113 | 113 | } |
| 114 | - catch( \Exception $e ) |
|
| 114 | + catch (\Exception $e) |
|
| 115 | 115 | { |
| 116 | 116 | return $e; |
| 117 | 117 | } |
@@ -37,8 +37,7 @@ discard block |
||
| 37 | 37 | break; |
| 38 | 38 | } |
| 39 | 39 | } |
| 40 | - } |
|
| 41 | - else |
|
| 40 | + } else |
|
| 42 | 41 | { |
| 43 | 42 | $this->conn = $this->connect( $host, $port, $user, $pass ); |
| 44 | 43 | } |
@@ -73,8 +72,7 @@ discard block |
||
| 73 | 72 | } |
| 74 | 73 | |
| 75 | 74 | return $this->queues[$name]; |
| 76 | - } |
|
| 77 | - catch( \Exception $e ) |
|
| 75 | + } catch( \Exception $e ) |
|
| 78 | 76 | { |
| 79 | 77 | throw new \Aimeos\MW\MQueue\Exception( $e->getMessage() ); |
| 80 | 78 | } |
@@ -110,8 +108,7 @@ discard block |
||
| 110 | 108 | $locale, $conntimeout, $timeout, null, |
| 111 | 109 | $keepalive, $heartbeat |
| 112 | 110 | ); |
| 113 | - } |
|
| 114 | - catch( \Exception $e ) |
|
| 111 | + } catch( \Exception $e ) |
|
| 115 | 112 | { |
| 116 | 113 | return $e; |
| 117 | 114 | } |