PHP code example of kumwe / access-context

1. Go to this page and download the library: Download kumwe/access-context 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/ */

    

kumwe / access-context example snippets




declare(strict_types=1);

emActor;
use Kumwe\Context\Value\ExecutionContext;
use Kumwe\Context\Value\SiteContext;

enum BackgroundActor: string implements SystemActor
{
    case Worker = 'system:worker';

    public function identifier(): string
    {
        return $this->value;
    }
}

$authority = new stdClass();
$context = ExecutionContext::issueSystem(
    $authority,
    BackgroundActor::Worker,
    SiteContext::fromString('namibia'),
    'operation-001',
);

assert($context->hasProvenance($authority));
echo json_encode($context->toArray(), JSON_THROW_ON_ERROR), PHP_EOL;