Beispiel #1
0
    {
        return true;
    }
    public function getFalse()
    {
        return false;
    }
    public function getNull()
    {
        return null;
    }
    public function getZero()
    {
        return 0;
    }
    public function getEmptystr()
    {
        return '';
    }
}
$exchange = new Generic('example.fanout', $config);
$producer = new EchoProducer();
$methods = get_class_methods($producer);
$count = 0;
while (true) {
    $method = $methods[array_rand($methods)];
    $exchange->send($producer->{$method}());
    echo "Sent message #{$count} ({$method})" . PHP_EOL;
    $count++;
    usleep(500000);
}
Beispiel #2
0
    {
        $continent_temperature = 'get' . ucfirst($continent) . 'Temperature';
        return "{$this->{$continent_temperature}()} weather every week in {$continent}";
    }
    public function getDaily($continent)
    {
        $continent_temperature = 'get' . ucfirst($continent) . 'Temperature';
        return "{$this->{$continent_temperature}()} weather every day in {$continent}";
    }
    private function getAfricaTemperature()
    {
        return 'warm';
    }
    private function getEuropeTemperature()
    {
        return 'cold';
    }
}
$exchange = new Generic('example.topic.weather', Config::get('amqp_params'));
$forecast = new DemoStation();
$count = 0;
while (true) {
    $continent = $forecast->continents[array_rand($forecast->continents)];
    $term = $forecast->terms[array_rand($forecast->terms)];
    $method = 'get' . ucfirst($term);
    $weather = $forecast->{$method}($continent);
    $exchange->send($weather, "example.topic.weather.{$continent}.{$term}");
    echo "Sent {$continent} {$term} forecast #{$count}: {$weather}" . PHP_EOL;
    $count++;
    usleep(500000);
}