PHP code example of phox / composable-jev

1. Go to this page and download the library: Download phox/composable-jev library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

phox / composable-jev example snippets


// PHP
use Phox\ComposableJev\Graph;
use Phox\ComposableJev\Oracle\Jev;

$triage = Graph::make('I was charged twice this month. This is the third time. Refund me now.')
    ->ask('refund', 'Is the customer asking for money back?', Graph::CONTEXT)
    ->ask('angry', 'Is the customer angry or out of patience?', Graph::CONTEXT)
    ->all('escalate', 'refund', 'angry');

$triage->run(Jev::make())->yes('escalate');                      // true

Graph::make('The export button has thrown an error for three days. Fix it today.')
    ->choose('team', 'Which team should handle this ticket?', Graph::CONTEXT, [
        'billing' => 'Payments, charges and refunds',
        'bugs' => 'Something in the product is broken',
        'other' => 'Anything else',
    ])
    ->score('severity', 'How much harm is the problem doing?', Graph::CONTEXT,
        ['None', 'A little', 'Some', 'A lot', 'It stops the customer working'])
    ->sum('serious', 'severity.3', 'severity.4')
    ->ask('senior', 'The ticket is for the team named, and serious is the chance its problem is '
        . 'serious. Should someone senior reply today?', [Graph::CONTEXT, 'team', 'serious']);

$latch = Graph::make()
    ->input('s', 'r')
    ->gate('q', 'nor', 'r', 'qbar')
    ->gate('qbar', 'nor', 's', 'q')
    ->startsAt('q', 0.0)
    ->startsAt('qbar', 1.0)
    ->ticker(Jev::make());

$latch->tick(['s' => 1]);
$latch->tick(['s' => 1]);          // a loop goes round once a tick, so setting takes two
$latch->tick()->yes('q');          // true: q holds with s off
$latch->tick(['r' => 1])->yes('q'); // false