-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathexample.php
37 lines (33 loc) · 973 Bytes
/
example.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
<?php
$autoLoader = require __DIR__ . '/vendor/autoload.php';
$autoLoader->add('Jimphle\\Example\\', __DIR__ . '/tests');
use Jimphle\Example\MessageHandler\BeObsceneHandler;
use Jimphle\Example\MessageHandler\SayHelloHandler;
use Jimphle\Messaging\MessageHandler\HandleMessagesToProcessDirectly;
use Jimphle\Messaging\MessageHandler\HandleMessage;
use Jimphle\Messaging\MessageHandlerProvider;
use Jimphle\Messaging\Command;
$messageHandlerDefinitions = array(
'say-hello' => new SayHelloHandler(),
'said-hello' => array(
new BeObsceneHandler()
)
);
$messagingContext = new HandleMessagesToProcessDirectly(
new HandleMessage(
new MessageHandlerProvider(
new ArrayObject(
$messageHandlerDefinitions
)
)
)
);
$response = $messagingContext->handle(
Command::generate(
'say-hello',
array(
'name' => 'World'
)
)
);
echo $response->answer . "\n";