Page Menu
Home
DevCentral
Search
Configure Global Search
Log In
Files
F13144333
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
2 KB
Referenced Files
None
Subscribers
None
View Options
diff --git a/src/BlackholeBroker.php b/src/BlackholeBroker.php
index b7ed842..562e4f8 100644
--- a/src/BlackholeBroker.php
+++ b/src/BlackholeBroker.php
@@ -1,68 +1,80 @@
<?php
namespace Keruald\Broker;
class BlackholeBroker extends Broker implements BuildableFromConfigInterface {
///
/// Broker implementation
///
/**
* Sends a message to the broker, which will silently discards it.
*
* @param string $message The message to send
*/
public final function sendMessage ($message) {
return $this;
}
+ /**
+ * Determines if the configuration wants an omnipotent blackhole
+ *
+ * @param array $params An array with omnipotence information
+ * @return bool
+ */
+ static private function configWantsOmnipotence ($params) {
+ return array_key_exists('omnipotence', $params)
+ &&
+ $params['omnipotence'];
+ }
+
/**
* Initializes a new instance of the broker from specified parameters
*
* @param array $params An array with omnipotence information
* @return Keruald\Broker\BlackholeBroker A connected instance of the broker
*/
static public function makeFromConfig ($params) {
$instance = new self;
- if ($params['omnipotence']) {
+ if (self::configWantsOmnipotence($params)) {
$instance->acceptAllMethodCalls();
}
return $instance;
}
///
/// Omnipotence to ease lightweight mock testing without any lib
///
/**
* @var bool
*/
private $acceptAllMethodCalls = false;
/**
* Configures the broker to accept every method call
*/
public function acceptAllMethodCalls () {
$this->acceptAllMethodCalls = true;
return $this;
}
/**
* Handles a method overloading call
*
* @param string $name The name of the method being called
* @param array $arguments An enumerated array containing the parameters
* passed to the method
*/
public function __call ($name, array $arguments) {
if ($this->acceptAllMethodCalls) {
return $this; // Brokers are intended to be fluent
}
throw new \BadFunctionCallException(
"Blackhole broker doesn't implement the $name method."
);
}
}
File Metadata
Details
Attached
Mime Type
text/x-diff
Expires
Fri, Nov 21, 16:58 (12 h, 34 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
3180492
Default Alt Text
(2 KB)
Attached To
Mode
rKBROKER Keruald Broker
Attached
Detach File
Event Timeline
Log In to Comment