1 | <?php |
||
2 | |||
3 | require_once __DIR__.'/../vendor/autoload.php'; |
||
4 | |||
5 | use Swarrot\Broker\Message; |
||
6 | use Swarrot\Broker\MessageProvider\CallbackMessageProvider; |
||
7 | use Swarrot\Consumer; |
||
8 | use Swarrot\Processor\Callback\CallbackProcessor; |
||
9 | |||
10 | $i = 0; |
||
11 | $messageProvider = new CallbackMessageProvider(function () use (&$i) { |
||
12 | $isPair = 0 == $i++ % 2; |
||
13 | |||
14 | return $isPair ? |
||
15 | new Message( |
||
16 | file_get_contents('https://query.yahooapis.com/v1/public/yql?q=select%20item.condition%20from%20weather.forecast%20where%20woeid%20%3D%20615702&format=json&env=store%3A%2F%2Fdatatables.org%2Falltableswithkeys') |
||
17 | ) : |
||
18 | null; |
||
19 | }); |
||
20 | |||
21 | $processor = new CallbackProcessor(function (Message $message, array $options) { |
||
0 ignored issues
–
show
|
|||
22 | $weather = json_decode($message->getBody(), true); |
||
23 | if (empty($weather['query']['results']['channel']['item']['condition']['text'])) { |
||
24 | echo 'Invalid Input'; |
||
25 | |||
26 | return; |
||
27 | } |
||
28 | |||
29 | printf("The weather is %s in Paris\n", $weather['query']['results']['channel']['item']['condition']['text']); |
||
30 | }); |
||
31 | |||
32 | $consumer = new Consumer($messageProvider, $processor); |
||
33 | |||
34 | $consumer->consume([]); |
||
35 |
This check looks for parameters that have been defined for a function or method, but which are not used in the method body.