Skip to content

Latest commit

 

History

History
44 lines (30 loc) · 1.04 KB

File metadata and controls

44 lines (30 loc) · 1.04 KB

CommandInterface

The contract that all commands must implement to be processed by the command bus.

Overview

CommandInterface marker interface for Commands.

Class Definition

interface CommandInterface {}

Purpose

Commands serve as:

  1. Data Transfer Objects - Carry data needed for a specific operation
  2. Intent Declaration - Clearly express what operation should be performed

Usage Examples

Basic Command Implementation

use Webware\CommandBus\CommandInterface;

final readonly class CreateUserCommand implements CommandInterface
{
    public function __construct(
        public string $email,
        public string $username,
        public ?string $displayName = null,
        public array $roles = ['user']
    ) {}
}

Related Components