22namespace Packaged \Queue \Provider \Amqp ;
33
44use Exception ;
5+ use Packaged \Helpers \ValueAs ;
56use Packaged \Queue \IBatchQueueProvider ;
67use Packaged \Queue \Provider \AbstractQueueProvider ;
78use Packaged \Queue \Provider \QueueConnectionException ;
@@ -335,17 +336,17 @@ protected function _getWaitTime()
335336
336337 protected function _getMandatoryFlag ()
337338 {
338- return ( bool ) $ this ->config ()->getItem ('mandatory ' , true );
339+ return ValueAs:: bool ( $ this ->config ()->getItem ('mandatory ' , true ) );
339340 }
340341
341342 protected function _getAutoDeclare ()
342343 {
343- return ( bool ) $ this ->config ()->getItem ('auto_declare ' , false );
344+ return ValueAs:: bool ( $ this ->config ()->getItem ('auto_declare ' , false ) );
344345 }
345346
346347 protected function _getPublishConfirm ()
347348 {
348- return ( bool ) $ this ->config ()->getItem ('publish_confirm ' , false );
349+ return ValueAs:: bool ( $ this ->config ()->getItem ('publish_confirm ' , false ) );
349350 }
350351
351352 protected function _getPushTimeout ()
@@ -535,7 +536,7 @@ protected function _getConnection($connectionMode)
535536 $ config ->getItem ('connection_timeout ' , 3 ),
536537 $ config ->getItem ('read_write_timeout ' , 3 ),
537538 null ,
538- ( bool ) $ config ->getItem ('keepalive ' , false ),
539+ ValueAs:: bool ( $ config ->getItem ('keepalive ' , false ) ),
539540 $ config ->getItem ('heartbeat ' , 0 )
540541 );
541542 }
@@ -544,10 +545,7 @@ protected function _getConnection($connectionMode)
544545 $ this ->_log ('AMQP host failed to connect ( ' . $ host . ') ' );
545546 array_shift ($ this ->_hosts );
546547 }
547- $ this ->_persistentDefault = (bool )$ config ->getItem (
548- 'persistent ' ,
549- false
550- );
548+ $ this ->_persistentDefault = ValueAs::bool ($ config ->getItem ('persistent ' , false ));
551549 $ this ->_lastConnectTimes [$ connectionMode ] = time ();
552550 }
553551
@@ -748,11 +746,11 @@ public function declareQueue()
748746 $ config = $ this ->config ();
749747 $ this ->_getChannel (self ::CONN_OTHER )->queue_declare (
750748 $ this ->_getQueueName (),
751- ( bool ) $ config ->getItem ('queue_passive ' , false ),
752- ( bool ) $ config ->getItem ('queue_durable ' , true ),
753- ( bool ) $ config ->getItem ('queue_exclusive ' , false ),
754- ( bool ) $ config ->getItem ('queue_autodelete ' , false ),
755- ( bool ) $ config ->getItem ('queue_nowait ' , false ),
749+ ValueAs:: bool ( $ config ->getItem ('queue_passive ' , false ) ),
750+ ValueAs:: bool ( $ config ->getItem ('queue_durable ' , true ) ),
751+ ValueAs:: bool ( $ config ->getItem ('queue_exclusive ' , false ) ),
752+ ValueAs:: bool ( $ config ->getItem ('queue_autodelete ' , false ) ),
753+ ValueAs:: bool ( $ config ->getItem ('queue_nowait ' , false ) ),
756754 new AMQPTable ((array )$ config ->getItem ('queue_args ' , null ))
757755 );
758756 return $ this ;
@@ -793,11 +791,11 @@ public function declareExchange()
793791 $ this ->_getChannel (self ::CONN_OTHER )->exchange_declare (
794792 $ this ->_getExchangeName (),
795793 (string )$ config ->getItem ('exchange_type ' , 'direct ' ),
796- ( bool ) $ config ->getItem ('exchange_passive ' , false ),
797- ( bool ) $ config ->getItem ('exchange_durable ' , true ),
798- ( bool ) $ config ->getItem ('exchange_autodelete ' , false ),
799- ( bool ) $ config ->getItem ('exchange_internal ' , false ),
800- ( bool ) $ config ->getItem ('exchange_nowait ' , false ),
794+ ValueAs:: bool ( $ config ->getItem ('exchange_passive ' , false ) ),
795+ ValueAs:: bool ( $ config ->getItem ('exchange_durable ' , true ) ),
796+ ValueAs:: bool ( $ config ->getItem ('exchange_autodelete ' , false ) ),
797+ ValueAs:: bool ( $ config ->getItem ('exchange_internal ' , false ) ),
798+ ValueAs:: bool ( $ config ->getItem ('exchange_nowait ' , false ) ),
801799 (array )$ config ->getItem ('exchange_args ' , null )
802800 );
803801 return $ this ;
0 commit comments