Skip to content

Commit

Permalink
Add demo script for PECL usage in billing service
Browse files Browse the repository at this point in the history
Introduce a new demo script `05-pecl.php` under the `demo` directory. This script sets up an Aspect-Oriented Programming (AOP) configuration and demonstrates error handling within a billing service.
  • Loading branch information
koriym committed Nov 4, 2024
1 parent ab9f892 commit f6ace02
Showing 1 changed file with 29 additions and 0 deletions.
29 changes: 29 additions & 0 deletions demo/05-pecl.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<?php

declare(strict_types=1);

namespace Ray\Aop\Demo;

use Ray\Aop\Aspect;
use Ray\Aop\Matcher;
use RuntimeException;

use const PHP_EOL;

require __DIR__ . '/bootstrap.php';

$aspect = new Aspect(__DIR__ . '/tmp');
$aspect->bind(
(new Matcher())->any(),
new IsContainsMatcher('charge'),
[new WeekendBlocker()]
);
$aspect->weave(__DIR__. '/src');

try {
$billingService = new RealBillingService();
echo $billingService->chargeOrder();
} catch (RuntimeException $e) {
echo $e->getMessage() . PHP_EOL;
exit(1);
}

0 comments on commit f6ace02

Please sign in to comment.