DataSift_StreamConsumer::factory PHP Method

factory() public static method

Factory function. Creates a StreamConsumer-derived object for the given type.
public static factory ( string $user, string $type, mixed $definition, string $eventHandler ) : DataSift_StreamConsumer
$user string Use DataSift_User object.
$type string Use the TYPE_ constants
$definition mixed CSDL string or a Definition object.
$eventHandler string The object that will receive events.
return DataSift_StreamConsumer The consumer object
    public static function factory($user, $type, $definition, $eventHandler)
    {
        $classname = 'DataSift_StreamConsumer_' . $type;
        if (!class_exists($classname)) {
            throw new DataSift_Exception_InvalidData('Consumer type "' . $type . '" is unknown');
        }
        return new $classname($user, $definition, $eventHandler);
    }

Usage Example

Ejemplo n.º 1
0
 /**
  * Returns a DataSift_StreamConsumer-derived object for the given hashes,
  * for the given type.
  *
  * @param string $type The consumer type for which to construct a consumer.
  * @param string $hashes An array containing hashes and/or Definition objects to be consumed.
  * @param DataSift_IStreamConsumerEventHandler $eventHandler The object that will receive events.
  *
  * @return DataSift_StreamConsumer The consumer object.
  * @throws DataSift_Exception_InvalidData
  * @see DataSift_StreamConsumer
  */
 public function getMultiConsumer($type = DataSift_StreamConsumer::TYPE_HTTP, $hashes, $eventHandler)
 {
     return DataSift_StreamConsumer::factory($this, $type, $hashes, $eventHandler);
 }
All Usage Examples Of DataSift_StreamConsumer::factory