for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
declare(strict_types=1);
namespace FondBot\Conversation;
use FondBot\Drivers\ReceivedMessage;
class IntentManager
{
/** @var Intent[] */
private $intents = [];
/** @var Intent */
private $fallbackIntent;
/**
* Register intents.
*
* @param array $intents
* @param string $fallbackIntent
*/
public function register(array $intents, string $fallbackIntent): void
$intents
This check looks from parameters that have been defined for a function or method, but which are not used in the method body.
$fallbackIntent
}
* Find intent.
* @param ReceivedMessage $message
* @return Intent|null
public function find(ReceivedMessage $message): ?Intent
foreach ($this->intents as $intent) {
foreach ($intent->activators() as $activator) {
if ($activator->matches($message) && $intent->passesAuthorization($message)) {
return $intent;
// Otherwise, return fallback intent
return $this->fallbackIntent;
* Add intent.
* @param Intent $intent
public function add(Intent $intent): void
if (!in_array($intent, $this->intents, true)) {
$this->intents[] = $intent;
* Set fallback intent.
public function setFallbackIntent(Intent $intent): void
$this->fallbackIntent = $intent;
This check looks from parameters that have been defined for a function or method, but which are not used in the method body.