You've already forked Php-Template
chore: add deployment configurations and tests for logger and dispatcher (#18)
All checks were successful
🧪✨ Tests Workflow / 🧪 ✨ Database Migrations (push) Successful in 2m54s
🧪✨ Tests Workflow / 🛡️ 🔒 License Check (push) Successful in 2m48s
🧪✨ Tests Workflow / 🛡️ 🔒 Library Audit (push) Successful in 3m9s
🧪✨ Tests Workflow / 📝 ✨ Code Lint (push) Successful in 3m9s
🧪✨ Tests Workflow / 🐙 🔍 Code Sniffer (push) Successful in 3m4s
🧪✨ Tests Workflow / 🧪 ✅ Unit Tests (push) Successful in 2m44s
All checks were successful
🧪✨ Tests Workflow / 🧪 ✨ Database Migrations (push) Successful in 2m54s
🧪✨ Tests Workflow / 🛡️ 🔒 License Check (push) Successful in 2m48s
🧪✨ Tests Workflow / 🛡️ 🔒 Library Audit (push) Successful in 3m9s
🧪✨ Tests Workflow / 📝 ✨ Code Lint (push) Successful in 3m9s
🧪✨ Tests Workflow / 🐙 🔍 Code Sniffer (push) Successful in 3m4s
🧪✨ Tests Workflow / 🧪 ✅ Unit Tests (push) Successful in 2m44s
Reviewed-on: #18 Co-authored-by: Ron Rise <ron@siteworxpro.com> Co-committed-by: Ron Rise <ron@siteworxpro.com>
This commit was merged in pull request #18.
This commit is contained in:
36
src/Attributes/Async/HandlesMessage.php
Normal file
36
src/Attributes/Async/HandlesMessage.php
Normal file
@@ -0,0 +1,36 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Siteworxpro\App\Attributes\Async;
|
||||
|
||||
use Attribute;
|
||||
|
||||
/**
|
||||
* Attribute to mark a class as a handler for a specific message class in an async workflow.
|
||||
*
|
||||
* Repeatable: attach multiple times to handle multiple message classes.
|
||||
*/
|
||||
#[Attribute(Attribute::TARGET_CLASS | Attribute::IS_REPEATABLE)]
|
||||
readonly class HandlesMessage
|
||||
{
|
||||
/**
|
||||
* Create a new HandlesMessage attribute.
|
||||
*
|
||||
* @param class-string $messageClass Fully-qualified class name of the message handled.
|
||||
*/
|
||||
public function __construct(
|
||||
public string $messageClass,
|
||||
) {
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the fully-qualified message class this handler processes.
|
||||
*
|
||||
* @return class-string
|
||||
*/
|
||||
public function getMessageClass(): string
|
||||
{
|
||||
return $this->messageClass;
|
||||
}
|
||||
}
|
||||
28
src/Attributes/Events/ListensFor.php
Normal file
28
src/Attributes/Events/ListensFor.php
Normal file
@@ -0,0 +1,28 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Siteworxpro\App\Attributes\Events;
|
||||
|
||||
use Attribute;
|
||||
|
||||
/**
|
||||
* Attribute to mark a class as an event listener for a specific event class.
|
||||
*
|
||||
* Apply this attribute to classes that subscribe to domain or application events.
|
||||
* Repeatable: can be attached multiple times to the same class to listen for multiple events.
|
||||
*
|
||||
* Targets: class only.
|
||||
*/
|
||||
#[Attribute(Attribute::TARGET_CLASS | Attribute::IS_REPEATABLE)]
|
||||
readonly class ListensFor
|
||||
{
|
||||
/**
|
||||
* Initialize the ListensFor attribute.
|
||||
*
|
||||
* @param class-string $eventClass Fully-qualified class name of the event to listen for.
|
||||
*/
|
||||
public function __construct(public string $eventClass)
|
||||
{
|
||||
}
|
||||
}
|
||||
66
src/Attributes/Guards/Jwt.php
Normal file
66
src/Attributes/Guards/Jwt.php
Normal file
@@ -0,0 +1,66 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Siteworxpro\App\Attributes\Guards;
|
||||
|
||||
use Attribute;
|
||||
use Siteworxpro\App\Services\Facades\Config;
|
||||
|
||||
/**
|
||||
* Attribute to guard classes or methods with JWT claim requirements.
|
||||
*
|
||||
* Apply this attribute to a class or method to declare the expected JWT issuer and/or audience.
|
||||
* If either the issuer or audience is an empty string, the value will be resolved from configuration:
|
||||
* - `jwt.issuer`
|
||||
* - `jwt.audience`
|
||||
*
|
||||
* Targets: class or method.
|
||||
*/
|
||||
#[Attribute(Attribute::TARGET_CLASS | Attribute::TARGET_METHOD)]
|
||||
readonly class Jwt
|
||||
{
|
||||
/**
|
||||
* Initialize the Jwt attribute with optional overrides for expected JWT claims.
|
||||
*
|
||||
* @param string $issuer Optional expected JWT issuer (`iss`). Empty string uses `Config::get('jwt.issuer')`.
|
||||
* @param string $audience Optional expected JWT audience (`aud`). Empty string uses `Config::get('jwt.audience')`.
|
||||
*/
|
||||
public function __construct(
|
||||
private string $issuer = '',
|
||||
private string $audience = '',
|
||||
) {
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the expected audience for validation.
|
||||
*
|
||||
* Returns the constructor-provided audience when non-empty; otherwise falls back to `jwt.audience` config.
|
||||
*
|
||||
* @return string The audience value to enforce.
|
||||
*/
|
||||
public function getAudience(): string
|
||||
{
|
||||
if ($this->audience === '') {
|
||||
return Config::get('jwt.audience') ?? '';
|
||||
}
|
||||
|
||||
return $this->audience;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the expected issuer for validation.
|
||||
*
|
||||
* Returns the constructor-provided issuer when non-empty; otherwise falls back to `jwt.issuer` config.
|
||||
*
|
||||
* @return string The issuer value to enforce.
|
||||
*/
|
||||
public function getIssuer(): string
|
||||
{
|
||||
if ($this->issuer === '') {
|
||||
return Config::get('jwt.issuer') ?? '';
|
||||
}
|
||||
|
||||
return $this->issuer;
|
||||
}
|
||||
}
|
||||
21
src/Attributes/Guards/Scope.php
Normal file
21
src/Attributes/Guards/Scope.php
Normal file
@@ -0,0 +1,21 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Siteworxpro\App\Attributes\Guards;
|
||||
|
||||
use Attribute;
|
||||
|
||||
#[Attribute(Attribute::TARGET_CLASS | Attribute::TARGET_METHOD)]
|
||||
readonly class Scope
|
||||
{
|
||||
public function __construct(
|
||||
private array $scopes = []
|
||||
) {
|
||||
}
|
||||
|
||||
public function getScopes(): array
|
||||
{
|
||||
return $this->scopes;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user